#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
struct Point {
ll x, y;
};
ll M = 250'010;
vector<ll> cnt(M,1);
ll n;
ll inf = 1e18;
vector<Point> pkt;
ll base = 1<<18;
ll kwadrat(ll x, ll y, ll r) {
ll res = 0;
for(int i=0; i<n; ++i) if(max(abs(pkt[i].x-x), abs(pkt[i].y-y)) <= r) res++;
return res;
}
ll find_nxt(ll i) {
ll lo = 0;
ll hi = 4e9;
if(cnt[i]==n) return inf;
while(lo < hi) {
ll mid = (lo+hi)/2;
if(kwadrat(pkt[i].x, pkt[i].y, mid) > cnt[i]) hi = mid;
else lo = mid+1;
}
cnt[i]++;
return lo;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll k;
cin >> n >> k;
pkt.resize(n);
for(ll i=0; i<n; ++i) {
ll x,y;
cin >> x >> y;
pkt[i] = {x+y,x-y};
}
priority_queue<pair<ll, ll>> pq;
for(ll i=0; i<n; ++i) {
ll x = find_nxt(i);
pq.push({-x, i});
}
vector<int> ans;
for(ll ile=0; ile<2*k; ++ile){
ans.push_back(-pq.top().first);
ll i =pq.top().second;
pq.pop();
pq.push({-find_nxt(i), i});
}
for(int i=0; i<ans.size(); i+=2) cout << ans[i] << "\n";
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |