Heim > Web-Frontend > HTML-Tutorial > Codeforces Round #274 (Div. 2) C. Exams_html/css_WEB-ITnose

Codeforces Round #274 (Div. 2) C. Exams_html/css_WEB-ITnose

WBOY
Freigeben: 2016-06-24 11:55:54
Original
1056 Leute haben es durchsucht

Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n 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 the i-th subject allowed him to take an exam before the schedule time on day bi (bi?

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.

Input

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 integers ai and bi (1?≤?bi?

Output

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.

Sample test(s)

input

35 23 14 2
Nach dem Login kopieren

output

input

36 15 24 3
Nach dem Login kopieren

output

题意:一个人要参加n场考试,考试规定时间是ai,但是可以提前到bi,他要按照时间的顺序参加,在同一个时间可以做若干件事情,求最早的考完时间

思路:先按照规定时间排序,然后是每次记录上次考试的时间

#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>typedef long long ll;using namespace std;const int maxn = 5005;struct Node {	ll x, y;} node[maxn];int cmp(Node a, Node b) {	if (a.x != b.x)		return a.x = ans)			ans = node[i].y;		else ans = node[i].x;	}	printf("%lld\n", ans);		return 0;}</algorithm></cstring></cstdio></iostream>
Nach dem Login kopieren



Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage