Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
150958 | lrf820215 | 电视节目安排 | C++ | 通过 | 100 | 2 MS | 244 KB | 702 | 2024-06-10 10:09:32 |
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; struct node{ int begin; int end; }; node tt[105]; int cmp(node a,node b){ return a.end<b.end||a.end==b.end&&a.begin<b.begin; } int main() { int n; int s=0; int k; while(scanf("%d",&n)!=EOF&&n){ for(int i=0;i<n;i++){ scanf("%d %d",&tt[i].begin,&tt[i].end); } sort(tt,tt+n,cmp); s+=1; k=0; for(int i=1;i<n;i++){ if(tt[i].begin>=tt[k].end){ s++; k=i; } } printf("%d\n",s); s=0; } return 0; }