POJ 2376 Cleaning Shifts
来源:互联网 发布:雾霾吸入 知乎 编辑:程序博客网 时间:2024/06/06 20:00
- Source Code
#include<iostream>#include<algorithm>using namespace std;struct node{int x, y;}cow[25002];bool cmp(node a, node b){return a.x < b.x;}int main(){int n, k;while (cin >> n >> k){bool xx = 0, yy = 0;for (int i = 0; i < n; i++){cin >> cow[i].x >> cow[i].y;if (cow[i].x == 1) xx = 1;if (cow[i].y == k) yy = 1;}if (xx != 1 || yy != 1){cout << "-1" << endl; continue;}sort(cow, cow + n, cmp); cow[n].x = 1000003;int start = 0, temp = 0; bool b = 0; int s = 0;for (int i = 0; i < n; i++){if (cow[i].x <= start+1){if (cow[i].y > temp) temp = cow[i].y, b = 1;if (cow[i + 1].x > start+1&&b){start = temp; s++; b = 0;}}}if (start >= k) cout << s << endl;else cout << "-1" << endl;}return 0;}
阅读全文
0 0
- POJ 2376 Cleaning Shifts
- POJ 2376 Cleaning Shifts
- poj 2376 Cleaning Shifts
- POJ-2376-Cleaning Shifts
- poj 2376 Cleaning Shifts
- POJ 2376 Cleaning Shifts
- POJ 2376 Cleaning Shifts
- poj 2376 Cleaning Shifts
- POJ 2376 Cleaning Shifts
- poj 2376 Cleaning Shifts
- POJ-2376 Cleaning Shifts
- POJ 2376Cleaning Shifts
- POJ 2376 Cleaning Shifts
- poj 2376 Cleaning Shifts
- POJ - 2376 Cleaning Shifts
- POJ 2376 Cleaning Shifts
- POJ 2376 Cleaning Shifts
- poj 2376 Cleaning Shifts
- java常用集合框架简单讲解
- 带你玩转Visual Studio——带你理解多字节编码与Unicode码
- [编译链接装载]之静态链接
- for循环中进行Promise异步操作的问题总结
- Matlab保存图像的方法总结
- POJ 2376 Cleaning Shifts
- 多个相同classname的控件中查找子控件(父控件text、resource-id为空,classname不是唯一...)
- Java多线程之线程返回值
- c#数据结构——单链表
- Spring Boot学习笔记----Schedule
- SQL入门 7 8 9 10 11 12 从查询中获得有效的结果
- LayaAir 自转的小球围绕着鼠标转动
- J作业
- open-falcon