1 solutions

  • 0
    @ 2025-5-24 12:05:03

    勤劳的虎鲸又来告你答案了 嘻嘻嘻嘻嘻嘻:)

    #include<bits/stdc++.h>
    using namespace std;
    struct f{
    	int x;
    	int y;
    };
    int n;
    const int M=1e6+2;
    f a[M];
    int s=1;
    bool cmp(f a,f b){
    	return a.y<b.y;
    }
    int main(){
    	cin>>n;
    	for(int i=1;i<=n;i++){
    		cin>>a[i].x>>a[i].y;
    	}
    	sort(a+1,a+1+n,cmp);
    	int t=a[1].y;
    	for(int i=2;i<=n;i++){
    		if(a[i].x>=t){
    			t=a[i].y;
    			s++;
    		}
    	}
    	cout<<s;
    	return 0;
    }
    
    • 1

    Information

    ID
    11
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    # Submissions
    2
    Accepted
    1
    Uploaded By