from typing import List, Tuple
def main():
NONE_DAY: int = -100
exm_cnt: int = int(input().strip())
table: List[Tuple[int, int]] = list()
for pos in range(0, exm_cnt):
inn: List[str] = input().strip().split(' ')
left: int = int(inn[0])
right: int = int(inn[1])
elem: Tuple[int, int] = (left, right)
table.append(elem)
table.sort()
last_exm_day_cnt: int = NONE_DAY
for pos in range(0, exm_cnt):
if last_exm_day_cnt <= table[pos][1]:
last_exm_day_cnt = table[pos][1]
else:
last_exm_day_cnt = table[pos][0]
print(last_exm_day_cnt)
main()
#include<bits/stdc++.h>
using namespace std;
constexpr int INF = 2100000000;
typedef long long ll;
typedef unsigned long long ULL;
constexpr ll INF64 = 1e18;
const int N = 2e5+10;
typedef pair<int, int> PII;
#define mysort(a) sort(a.begin(),a.end());
void solve() {
int n;
cin >> n;
vector<PII> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i].first >> a[i].second;
}
mysort(a);
int res = 0;
for (int i = 0; i < n; i++) {
int t = min(a[i].first, a[i].second);
if (t < res) {
res = max(a[i].first, a[i].second);
}
else {
res = t;
}
}
cout << res << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
solve();
return 0;
}
1920. Build Array from Permutation | 494. Target Sum |
797. All Paths From Source to Target | 1547B - Alphabetical Strings |
1550A - Find The Array | 118B - Present from Lena |
27A - Next Test | 785. Is Graph Bipartite |
90. Subsets II | 1560A - Dislike of Threes |
36. Valid Sudoku | 557. Reverse Words in a String III |
566. Reshape the Matrix | 167. Two Sum II - Input array is sorted |
387. First Unique Character in a String | 383. Ransom Note |
242. Valid Anagram | 141. Linked List Cycle |
21. Merge Two Sorted Lists | 203. Remove Linked List Elements |
733. Flood Fill | 206. Reverse Linked List |
83. Remove Duplicates from Sorted List | 116. Populating Next Right Pointers in Each Node |
145. Binary Tree Postorder Traversal | 94. Binary Tree Inorder Traversal |
101. Symmetric Tree | 77. Combinations |
46. Permutations | 226. Invert Binary Tree |