T467972
  • 板块灌水区
  • 楼主o0_yuanshen_0o
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/6/28 19:59
  • 上次更新2024/6/28 20:08:07
查看原帖
T467972
1359886
o0_yuanshen_0o楼主2024/6/28 19:59
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
struct hd{
    int st,ed;
}a[N];
int n,cnt,last;
bool cmp(hd x , hd y)
{
    return x.ed<y.ed;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i].st>>a[i].ed;
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++)
    {
        if(a[i].st>=last)
        {
            cnt++;
            last=a[i].ed;
        }
    }
    cout<<cnt;
}
2024/6/28 19:59
加载中...