#include<bits/stdc++.h>
// #include<atcoder/modint>
#define pb push_back
#define mp make_pair
#define rs resize
#define ft front()
#define bk back()
#define int long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vc vector<char>
#define vb vector<bool>
#define mii map<int,int>
#define f0r(i,n) for(int i=0;i<n;i++)
#define FOR(i,k,n) for(int i=k;i<n;i++)
#define r0f(i,n) for(int i = n-1; i >= 0; i--)
#define R0F(i,k,n) for(int i = n-1; i >= k; i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define in(a) int a; cin>>a
#define in2(a,b) int a,b; cin>>a>>b
#define in3(a,b,c) int a,b,c; cin>>a>>b>>c
#define in4(a,b,c,d) int a,b,c,d; cin>>a>>b>>c>>d
#define vin(v,n); vi v(n); f0r(i,n){cin>>v[i];}
#define out(a) cout<<a<<'\n'
#define out2(a,b) cout<<a<<' '<<b<<'\n'
#define out3(a,b,c) cout<<a<<' '<<b<<' '<<c<<'\n'
#define out4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<'\n'
#define pout(a) cout<<a.first<<' '<<a.second<<'\n'
#define vout(v) for(auto u : v){cout<<u<<' ';} cout<<endl
#define dout(a) cout<<a<<' '<<#a<<endl
#define dout2(a,b) cout<<a<<' '<<#a<<' '<<b<<' '<<#b<<endl
#define yn(x); if(x){cout<<"YES"<<'\n';}else{cout<<"NO"<<'\n';}
#define p2(x) (1LL << (x))
#define pct(x) (__builtin_popcountll(x))
#define ist(x,y) ((x >> y) & 1)
template<class T, class U> bool ckmin(T& a, const U& b) { return (T)b < a ? a = (T)b, 1 : 0; }
template<class T, class U> bool ckmax(T& a, const U& b) { return a < (T)b ? a = (T)b, 1 : 0; }
const int leg = 1e9 + 7;
const int mod = 998244353;
using namespace std;
// using namespace atcoder;
// using mint = modint998244353;
vpii pts; int n, k;
multiset<int>ans;
bool check(int D, bool brk){
ans.clear(); set<pii> g; int ptr = 0;
f0r(i, n){
while(ptr < n && pts[ptr].first < pts[i].first - D){
g.erase(g.find(mp(pts[ptr].second, pts[ptr].first))); ptr++;
}
auto it = g.lower_bound(mp(pts[i].second - D, -4e18));
for(; it != g.end() && (*it).first <= pts[i].second + D; it++){
// if(D == 3){
// pout(pts[i]); pout((*it)); cout<<'\n';
// }
ans.insert(max(abs(pts[i].first - (*it).second), abs(pts[i].second - (*it).first))); if(ans.size() >= k && brk)return 1;
}
g.insert(mp(pts[i].second, pts[i].first));
}
return 0;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
//ifstream cin(".in");
//ofstream cout(".out");
cin>>n>>k; f0r(i,n){in2(x,y); pts.pb(mp(x+y,x-y));} sort(all(pts));
// for(auto u : pts)pout(u); cout<<'\n';
int lo = 0; int hi = 4e9 + 5;
while(lo < hi){
int mid = lo + hi >> 1;
if(check(mid, 1)){
hi = mid;
}
else lo = mid + 1;
} //dout(lo);
check(lo, 0); int gw = 0;
for(auto u : ans){
cout<<u<<'\n'; ++gw; if(gw == k)break;
}
}
# | 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... |