cf cmp!
来源:互联网 发布:淘宝今年双十一销售额 编辑:程序博客网 时间:2024/04/29 22:34
Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactlyn exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. Besides, he can take several exams on one day, and in any order.
According to the schedule, a student can take the exam for the i-th subject on the day number ai. However, Valera has made an arrangement with each teacher and the teacher of thei-th subject allowed him to take an exam before the schedule time on daybi (bi < ai). Thus, Valera can take an exam for the i-th subject either on dayai, or on daybi. All the teachers put the record of the exam in the student's record book on the day of the actual exam and write down the date of the mark as number ai.
Valera believes that it would be rather strange if the entries in the record book did not go in the order of non-decreasing date. Therefore Valera asks you to help him. Find the minimum possible value of the day when Valera can take the final exam if he takes exams so that all the records in his record book go in the order of non-decreasing date.
The first line contains a single positive integer n (1 ≤ n ≤ 5000) — the number of exams Valera will take.
Each of the next n lines contains two positive space-separated integersai andbi (1 ≤ bi < ai ≤ 109) — the date of the exam in the schedule and the early date of passing the i-th exam, correspondingly.
Print a single integer — the minimum possible number of the day when Valera can take the last exam if he takes all the exams so that all the records in his record book go in the order of non-decreasing date.
35 23 14 2
2
36 15 24 3
6
In the first sample Valera first takes an exam in the second subject on the first day (the teacher writes down the schedule date that is 3). On the next day he takes an exam in the third subject (the teacher writes down the schedule date, 4), then he takes an exam in the first subject (the teacher writes down the mark with date 5). Thus, Valera takes the last exam on the second day and the dates will go in the non-decreasing order: 3, 4, 5.
In the second sample Valera first takes an exam in the third subject on the fourth day. Then he takes an exam in the second subject on the fifth day. After that on the sixth day Valera takes an exam in the first subject.
在cmp上出了问题
#include<stdio.h>#include<algorithm>using namespace std;struct node{int a,b;} a[100010];int cmp(node a,node b){if(a.a == b.a)return a.b<b.b;return a.a<b.a;}int main(){int n;while(~scanf("%d",&n)){int max = -1; for(int i=0;i<n;i++) scanf("%d%d",&a[i].a,&a[i].b); sort(a,a+n,cmp); for(int i=0;i<n;i++){ if(a[i].b>=max)max = a[i].b; else max = a[i].a; } printf("%d\n",max);}}
- cf cmp!
- CMp
- cmp
- cmp
- cmp
- CMP
- cmp
- 开发CMP
- CMP简介
- EJB CMP
- CMP详解
- CMP & BMP
- cmp test
- base-cmp
- cmp指令
- CMP指令
- cmp指令
- cmp函数
- csdn的windows live writer xmlrpc地址
- 大牛链接
- 5分钟理解 Javascript 闭包
- [LeetCode]Simplify Path
- Lucene中使用高效压缩来压缩stored fields
- cf cmp!
- 后年将有60亿部手机!
- 推荐一个拥有大量开源项目和开发工具的网站
- Opencv对加载图像时路径格式转换
- python解析搜狗网页源代码:取搜索引擎返回的前page_num*10个链接的url(待续)
- wap 机试 旅行家问题
- 排序算法之三----选择排序
- Understanding 9i Real Application Clusters Cache Fusion (Doc ID 139436.1)
- Select、Poll与Epoll比较