求助大佬P1803CE
  • 板块灌水区
  • 楼主Butterfly___qwq
  • 当前回复5
  • 已保存回复5
  • 发布时间2022/6/25 10:03
  • 上次更新2023/10/27 22:38:20
查看原帖
求助大佬P1803CE
529458
Butterfly___qwq楼主2022/6/25 10:03
#include<bits/stdc++.h>
using namespace std;
struct cop{
    int s;
    int e;
}n[1000001];
bool cmp(cop a,cop b){
    return a.e>b.e;
}
int main(){
    int t;cin>>t;int p=0,tot=0;
    for(int i=1;i<=t;i++)cin>>n[i].s>>n[i].e;
    sort(n+1,n+t+1,cmp);
    for(int i=1;i<=n;i++)if(p<=n[i].s){
        p=n[i].e;tot++;}
    cout<<tot<<endl;
    return 0;
}

编译信息:https://www.luogu.com.cn/record/77856795

2022/6/25 10:03
加载中...