蒟蒻求助,3RE
查看原帖
蒟蒻求助,3RE
1060965
fanjiajun_U楼主2024/1/22 11:55
#include<bits/stdc++.h>
struct node{
	int shi;
	int zhong;
};
bool cmp(node a,node b){
	if(a.zhong<b.zhong){
		return true;
	}else{
		return false;
	}
}
node a[1000050];
int n,cnt=1;
using namespace std;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].shi>>a[i].zhong;
	}
	sort(a+1,a+1+n,cmp);
	int k=a[1].zhong;
	for(int i=2;i<=n;i++){
		if(a[i].shi>=k){
			cnt++;
			k=a[i].zhong;
		}
	}
	cout<<cnt;
	return 0;
}
2024/1/22 11:55
加载中...