0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-30 20:56:29 +00:00
OI-codes/Codeforces/845/C/C.cpp

33 lines
717 B
C++
Raw Normal View History

2021-11-19 09:01:13 +00:00
#include <bits/stdc++.h>
2020-11-17 11:58:05 +00:00
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) {
return a.first == b.first ? a.second < b.second : a.first < b.first;
}
int main() {
int n;
pair<int, int> p[200005];
cin >> n;
2021-11-19 09:01:13 +00:00
for (int i = 0; i < n; i++) {
2020-11-17 11:58:05 +00:00
cin >> p[i].first >> p[i].second;
}
2021-11-19 09:01:13 +00:00
sort(p, p + n, cmp);
2020-11-17 11:58:05 +00:00
int tv1 = -1, tv2 = -1;
2021-11-19 09:01:13 +00:00
for (int i = 0; i < n; i++) {
if (p[i].first > tv1) {
2020-11-17 11:58:05 +00:00
tv1 = p[i].second;
2021-11-19 09:01:13 +00:00
} else {
if (p[i].first > tv2) {
2020-11-17 11:58:05 +00:00
tv2 = p[i].second;
2021-11-19 09:01:13 +00:00
} else {
2020-11-17 11:58:05 +00:00
cout << "NO" << endl;
return 0;
}
}
}
cout << "YES" << endl;
return 0;
}