Problem - C - Codeforces
题目意思 你有2台电视,问你能不能看完视频
解题思路
可以定义两个变量 如果俩个变量在看电视但是下一个节目开始了,那就说明看不完全部节目
#include"bits/stdc++.h" #define ll long long #define pi pair#define inf 0x3f3f3f3f #define _for(i,a,b) for(int i=a;i<=b;i++) #define for_(i,a,b) for(int i=a;i=b;i--) #define fr_(i,a,b) for(int i=a;i>b;i--) #define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) using namespace std; const int N = 2e5+5; const ll mod = 1e9+7; const double lp=1.000000011; map mp; int n,x; int a[N]; struct node{ int l,r; }arr[N]; bool cmp(node s1, node s2){ if(s1.l != s2.l) return s1.l > n; _for(i,1,n) cin >> arr[i].l>> arr[i].r; sort(arr+1,arr+1+n,cmp); int q = -1 ,w = -1; _for(i,1,n){ if(q < arr[i].l){ q=arr[i].r; }else if(w < arr[i].l){ w=arr[i].r; }else{ cout << "NOn"; return ; } } cout << "YESn"; } int main() { IOS; solve(); return 0; }



