CF845C Two TVs
:::素都会根据元素的键值自动排序

#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<bits/stdc++.h> #define ll long long #define ddd printf("-----------------debug\n"); using namespace std; const ll maxn=1e8+2; int read() { int res=0,f=1; char ch=getchar(); while(isdigit(ch)==0){ if(ch=='-') f=-1; ch=getchar(); } while(isdigit(ch)){ res=res*10+ch-'0'; ch=getchar(); } return f*res; } int n; map <int,int> a;// ->map <int,int> a int main() { ios::sync_with_stdio(false); cin.tie(0); n=read(); for(int i=1;i<=n;i++) { int l,r; l=read();r=read(); //rr=max(rr,r); a[l]+=1,a[r+1]-=1; } ll ans=0; for(map<int,int>::iterator it=a.begin();it!=a.end();it++){ ans+=it->second; // cout<<a[i]<<endl; //ddd if(ans>=3){ cout<<"NO"<<'\n'; return 0; } } cout<<"YES"<<'\n'; return 0; }