//gm --- akezhon
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define tm (tl+tr)/2
#define TL v+v, tl, tm
#define TR v+v+1, tm+1, tr
#define DA l <= tl && tr <= r
#define NE r < tl || tr < l
#define double long double
#define int long long
#define y1 osidfhj
using namespace std;
const int N=250007;
const int mod=998244353;
const int inf=2e10;
int n, k;
pii a[N];
int check(int l, int r, int d){
int ans=0;
for(int i=1; i <= n; i++){
for(int j=i+1; j <= n; j++){
if(abs(a[i].F-a[j].F) > d)break;
if(abs(a[i].F-a[j].F) + abs(a[i].S-a[j].S) <= d)ans++;
if(ans > k)return inf;
}
}
return ans;
}
vector<int>vec;
void show(int l, int r, int d){
for(int i=1; i <= n; i++){
for(int j=i+1; j <= n; j++){
if(abs(a[i].F-a[j].F) > d)break;
if(abs(a[i].F-a[j].F) + abs(a[i].S-a[j].S) <= d)vec.pb(abs(a[i].F-a[j].F) + abs(a[i].S-a[j].S));
}
}
}
void AlemAmenov(){
cin >> n >> k;
for(int i=1; i <= n; i++){
cin >> a[i].F >> a[i].S;
}
sort(a+1, a+1+n);
// cout << check(1, n, 4) << '\n';
int l=0, r=4e9, ans;
while(l <= r){
int m=(l+r)/2;
if(k <= check(1, n, m))r=m-1, ans=m;
else l=m+1;
}
if(check(1, n, ans) != k)ans--;
show(1, n, ans);
while(vec.size() != k)vec.pb(ans+1);
sort(all(vec));
for(int i : vec){
cout << i << '\n';
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int RealName=1;
// cin >> RealName;
// freopen("newbarn.in", "r", stdin);
// freopen("newbarn.out", "w", stdout);
while(RealName--)
AlemAmenov();
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... |