正文
增加 8 行删除 8 行
1234511 行未改动171819202122232425262728295 行未改动3536373839404142434445464748495051525354554 行未改动606162636465666768```#include<bits/stdc++.h>using namespace std;struct aaa{int x,y;11 行未改动q.push({a[i].y,a[i].x});p.push({a[i].y,a[i].x});}if(!q.empty()){if(abs(q.top().first-p.top().first)>=k){return 1;}}for(;i<n;i++){q.push({a[i].y,a[i].x});while(q.top().second<a[i].x-x){// cout<<q.top().second<<endl;5 行未改动p.pop();}// cout<<q.top().first<<endl;if(abs(q.top().first-p.top().first)>=k){return 1;}}return 0;}int main(){ios::sync_with_stdio(0);cin.tie(0);cin>>n>>k;for(int i=0;i<n;i++){cin>>a[i].x>>a[i].y;}sort(a,a+n,cmp);int l=0,r=1e9+10;while(l<r-1){4 行未改动}else{l=mid;}}if(r==1e9+10) cout<<-1;else cout<<r<<endl;return 0;}1234511 行未改动171819202122232425262728295 行未改动3536373839404142434445464748495051525354554 行未改动606162636465666768```#include<bits/stdc++.h>using namespace std;struct aaa{int x,y;11 行未改动q.push({a[i].y,a[i].x});p.push({a[i].y,a[i].x});}if(!q.empty()){if(abs(q.top().first-p.top().first)>=k){return 1;}}for(;i<n;i++){q.push({a[i].y,a[i].x});while(q.top().second<a[i].x-x){// cout<<q.top().second<<endl;5 行未改动p.pop();}// cout<<q.top().first<<endl;if(abs(q.top().first-p.top().first)>=k){return 1;}}return 0;}int main(){ios::sync_with_stdio(0);cin.tie(0);cin>>n>>k;for(int i=0;i<n;i++){cin>>a[i].x>>a[i].y;}sort(a,a+n,cmp);int l=0,r=1e9+10;while(l<r-1){4 行未改动}else{l=mid;}}if(r==1e9+10) cout<<-1;else cout<<r<<endl;return 0;}