From b37a3d66b5ec595dbadc55f8e9b41c6f7c77a715 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Tue, 17 Nov 2020 19:58:05 +0800 Subject: [PATCH] CF845C Two TVs R42073332 --- problem/CF845C/CF845C.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 problem/CF845C/CF845C.cpp diff --git a/problem/CF845C/CF845C.cpp b/problem/CF845C/CF845C.cpp new file mode 100644 index 00000000..d802e0af --- /dev/null +++ b/problem/CF845C/CF845C.cpp @@ -0,0 +1,34 @@ +#include + +using namespace std; + +bool cmp(pair a, pair b) { + return a.first == b.first ? a.second < b.second : a.first < b.first; +} + +int main() { + int n; + pair 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; +}