Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
133908 | 谢思涵 | 监测点 | C++ | 通过 | 100 | 4 MS | 244 KB | 462 | 2024-03-02 10:29:57 |
#include <iostream> #include <algorithm> using namespace std; struct Q { int l, r; }a[110]; bool cmp(Q a, Q b) {return a.r < b.r;} int main() { int t; cin >> t; for(int q = 1; q <= t; q++) { int n; cin >> n; for(int i = 1; i <= n; i++) cin >> a[i].l >> a[i].r; sort(a + 1, a + n + 1, cmp); int cnt = 1, c = a[1].r; for(int i = 2; i <= n; i++) if(a[i].l > c) {cnt++; c = a[i].r;} cout << cnt << endl; } return 0; }