Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
133833 | 莫栋涛 | 电视节目安排 | C++ | 解答错误 | 12 | 4 MS | 252 KB | 542 | 2024-03-02 09:44:19 |
#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; if (tvs[i+1].second <= ed) { continue; } ans++; curtime = ed; } cout << ans << endl; } }