为什么得80(-oo-)
查看原帖
为什么得80(-oo-)
1373509
Himborne楼主2024/8/24 21:10
#include<bits/stdc++.h>
using namespace std;
struct M{
	int start; 
	int end;
}M1[1000005];
bool compare(M a, M b){
	return a.end < b.end;
}
int main(){
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d %d",&M1[i].start,&M1[i].end);
	sort(M1,M1+n-1,compare);
	int pos = 0; 
	int ans=0;
	for(i=0;i<n;i++){
		if(pos<=M1[i].start)
		{
			pos = M1[i].end;
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}
2024/8/24 21:10
加载中...