Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
133808 | 凌艺樽 | 电视节目安排 | C++ | 通过 | 100 | 4 MS | 260 KB | 524 | 2024-03-02 09:31:07 |
#include<bits/stdc++.h> using namespace std; const int N=2e3+10; int n; struct TV{ int st,ed; }a[N]; bool cmp(TV x,TV y) { return x.st<y.st; } int main() { while(cin>>n && n) { for(int i=1;i<=n;++i) { cin>>a[i].st>>a[i].ed; } sort(a+1,a+n+1,cmp); int end=-1000,ans=0; for(int i=1;i<=n;++i) { if(end<=a[i].st) { end=a[i].ed; ans++; } else { if(a[i].ed<end) { end=a[i].ed; } } } cout<<ans<<'\n'; } return 0; }