排序题
2026-02-05 17:23:43
发布于:北京
0阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
pair<int,int>p[200005];
int main(){
int n,d;
cin>>n>>d;
for(int i=1;i<=n;i++) cin>>p[i].first>>p[i].second;
sort(p+1,p+n+1);
int out=2e9;
int ans=0;
for(int i=n;i>=1;i--){
if(p[i].second<out){
ans++;
out=p[i].first-d+1;
}
}
cout<<ans;
return 0;
}
这里空空如也


有帮助,赞一个