Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
133796 | 凌艺樽 | 监测点 | C++ | 解答错误 | 0 | 4 MS | 252 KB | 559 | 2024-03-02 09:22:54 |
#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) { if(x.st!=y.st)return x.ed<y.ed; else 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=0,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; }