Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
133844 | 莫栋涛 | 电视节目安排 | C++ | 通过 | 100 | 3 MS | 256 KB | 622 | 2024-03-02 09:50:56 |
#include <bits/stdc++.h> #define ll long long using namespace std; pair<int, int> tvs[105]; int main() { while (true) { int n; cin >> n; if (n == 0) return 0; for (int i = 1; i <= n; i++) { cin >> tvs[i].first >> tvs[i].second; } sort(tvs+1, tvs+n+1); long long ans = 0, curtime=0; for (int i = 1; i <= n; i++) { if (curtime > tvs[i].first) continue; int ed = tvs[i].second; for (int j = i+1; j <= n; j++) { if (tvs[j].first > ed) break; if (tvs[j].second <= ed) goto fkcpp; } ans++; curtime = ed; fkcpp: ; } cout << ans << endl; } }