问题标题: 酷町堂:3262 音乐节

0
0
已解决
宣瑞涵
宣瑞涵
高级守护
高级守护

题目链接: 酷町堂:3262

#include<iostream>

#include <algorithm>

using namespace std;

struct STU{

    int st,ed;

}a[205];

bool cmp(STU x,STU y){

    if(x.ed!=y.ed){

        return x.ed<y.ed;

    }

    return x.st>y.st;

}

int main(){

    long long n,cnt=0,m;

cin>>n;

    for(int i=1;i<=n;i++){

        cin>>a[i].st>>a[i].ed;

    }

    sort(a+1,a+n+1,cmp);

    m=a[1].ed;

    cnt++;

    for(int i=2;i<=n;i++){

        if(m<=a[i].st){

            m=a[i].ed;

            cnt++;

        }

    }

    cout<<cnt;

    return 0;

}


0
我要回答