最后三个RE了,求解
查看原帖
最后三个RE了,求解
1273240
ksqsg楼主2024/4/5 12:34
#include <iostream>
#include <algorithm>
#define N 100010
using namespace std;

struct atc
{
    int s,e;
}a[N];
bool cmp(atc x,atc y)
{
    if(x.e!=y.e) return x.e<y.e;
}
int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i].s >>a[i].e;
    }
    sort(a,a+n,cmp);
    int t=-2e9,cnt=0;
    for(int i=0;i<n;i++)
    {
        if(t<=a[i].s)
        {
            cnt++;
            t=a[i].e;
        }
    }
    cout << cnt;
    return 0;
}

2024/4/5 12:34
加载中...