#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
const int mxN = (int)2.5e5+10;
int n, K;
vector<int> ans;
vector<array<int,2>> v;
bool calc(int i, int j){ return max(abs(v[i][0]-v[j][0]),abs(v[i][1]-v[j][1])); }
bool chk(int d){
set<pair<int,int>> S; S.clear(); ans.clear();
for(int i=0, j=0; i < n and sz(ans)<K; i++){
while(v[i][0]-v[j][0]>d) S.erase({v[j][1],j}), j++;
auto itr1 = S.lower_bound({v[i][1]-d,-1});
auto itr2 = S.upper_bound({v[i][1]+d+1,-1});
for(; itr1!=itr2 and sz(ans)<K; itr1++)
ans.pb(calc(itr1->second,i));
S.insert({v[i][1],i});
}
return sz(ans)>=K;
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> K; int x, y;
for(int i = 0; i < n; i++)
cin >> x >> y, v.pb({x+y,x-y});
sort(all(v));
int l = 0, r = (int)4e9;
while(l<r){
int mid = (l+r)>>1;
if(chk(mid)) r=mid;
else l=mid+1;
}
chk(l-1); sort(all(ans)); while(sz(ans)<K) ans.pb(l);
for(auto u : ans) cout << u << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
115 ms |
2824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
366 ms |
8660 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
230 ms |
4504 KB |
Output is correct |
2 |
Correct |
307 ms |
4448 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
126 ms |
4488 KB |
Output is correct |
5 |
Correct |
390 ms |
4556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
230 ms |
4504 KB |
Output is correct |
2 |
Correct |
307 ms |
4448 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
126 ms |
4488 KB |
Output is correct |
5 |
Correct |
390 ms |
4556 KB |
Output is correct |
6 |
Incorrect |
469 ms |
4468 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
115 ms |
2824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
115 ms |
2824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |