Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
133872 | 罗恩祥 | 电视节目安排 | C++ | 通过 | 100 | 5 MS | 256 KB | 557 | 2024-03-02 10:10:09 |
#include <bits/stdc++.h> using namespace std; #define int long long struct TV { int b,e; } lst[105]; bool cmp(TV t1,TV t2) { if(t1.e == t2.e) return t1.b < t2.b; return t1.e < t2.e; } signed main() { int n; while(cin >> n && n != 0) { for(int i = 1;i <= n;i++) cin >> lst[i].b >> lst[i].e; sort(lst+1,lst+1+n,cmp); int B = 0,E = 0; int sum = 0; for(int i = 1;i <= n;i++) { if(lst[i].b >= E || lst[i].e <= B) { sum ++; B = lst[i].b; E = lst[i].e; } } cout << sum << endl; } }