mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2025-02-17 15:26:49 +00:00
CF845C Two TVs
R42073332
This commit is contained in:
parent
9f4f85ea72
commit
b37a3d66b5
34
problem/CF845C/CF845C.cpp
Normal file
34
problem/CF845C/CF845C.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include<bits/stdc++.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
for(int i = 0 ; i < n ; i++) {
|
||||||
|
cin >> p[i].first >> p[i].second;
|
||||||
|
}
|
||||||
|
sort(p, p+n, cmp);
|
||||||
|
int tv1 = -1, tv2 = -1;
|
||||||
|
for(int i = 0 ; i < n ; i++) {
|
||||||
|
if(p[i].first > tv1) {
|
||||||
|
tv1 = p[i].second;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(p[i].first > tv2) {
|
||||||
|
tv2 = p[i].second;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << "NO" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << "YES" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user