ans

wyz2011 2023-11-25 16:11:13 4 返回题目

#include<bits/stdc++.h>
using namespace std;
struct node{
	int b,e;
}a[10005];
bool cmp(node x,node y){
	return x.e<y.e;
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].b>>a[i].e;
	} 
	sort(a+1,a+1+n,cmp);
	int s=1,end=a[1].e;
	for(int i=2;i<=n;i++){
		if(a[i].b>end) end=a[i].e,s++; 
	}
	cout<<s;
	return 0;
}
{{ vote && vote.total.up }}