Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
133900 罗恩祥 监测点 C++ 通过 100 4 MS 252 KB 677 2024-03-02 10:26:51

Tests(10/10):


#include <bits/stdc++.h> using namespace std; #define int long long struct line { int b,e; } lst[105]; bool cmp(line l1,line l2) { if(l1.e == l2.e) return l1.b < l2.b; return l1.e < l2.e; } signed main() { long long n; cin >> n; while(n--) { int K; cin >> K; for(int i = 1;i <= K;i++) cin >> lst[i].b >> lst[i].e; sort(lst+1,lst+1+K,cmp); int N = lst[1].e; int sum = 1; for(int i = 2;i <= K;i++) { if(lst[i].e >= N && lst[i].b <= N) continue; else if(lst[i-1].b >= lst[i].b && lst[i].e < N) { N = lst[i].e; } else { sum++; N = lst[i].e; } } cout << sum << endl; } }


测评信息: