Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
133942 凌艺樽 监测点 C++ 通过 100 4 MS 360 KB 634 2024-03-02 10:54:34

Tests(10/10):


#include<bits/stdc++.h> using namespace std; const int N=1e5+10; int n,x; bool f[N]; struct point{ int s,e; }a[N]; bool cmp(point x,point y) { if(x.e==y.e) return x.s<y.s; return x.e<y.e; } int main() { cin>>x; while(x--) { cin>>n; memset(f,0,sizeof(f)); int ans=0; for(int i=1;i<=n;++i) { cin>>a[i].s>>a[i].e; } sort(a+1,a+n+1,cmp); for(int i=1;i<=n;++i) { bool f1=0; for(int j=a[i].s;j<=a[i].e;++j) { if(f[j]==1) { f1=1; break; } } if(!f1) { f[a[i].e]=1; ans++; } } cout<<ans<<'\n'; } return 0; }


测评信息: