#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii ;
typedef pair<ll, ll> pll ;
typedef vector<pii> vii ;
typedef vector<int> veci ;
typedef vector<pll> vll ;
typedef vector<ll> vecll;
// find_by_order order_of_key
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define Mp make_pair
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
#define set_dec(x) cout << fixed << setprecision(x);
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define lb lower_bound
#define ub upper_bound
#define for1(n) for(int i=1;i<=n;i++)
#define for0(n) for(int i=0;i<n;i++)
#define forn(n) for(int i=n;i>0;i--)
#define pq priority_queue <pii, vector<pii>, greater<pii>>
#define int ll
const ll mod = 1e9+7 ;// 998244353 ;// 1e9+9;
ll inf=1e18;
const int N=1e6+100,L=21,bs=701,NN=1e6;
int B[N],C[N],D[N],E[N],n,m,k,q,dp[N],pre[N],dist[N],vis[N];
vector<int>g[N];
vector<ll>ans;
pii A[N];
bool check(ll t){
set<pll>C;
int r=1;
for1(n){
while(A[r].F<=t+A[i].F && r<=n){
auto it=C.lb({A[r].S-t,-mod*2});
while(1){
if(it==C.end())break;
ll dis=max(max((ll((*it).F)-ll(A[r].S)),-(ll((*it).F)-ll(A[r].S))),max((ll((*it).S)-ll(A[r].F)),-(ll((*it).S)-ll(A[r].F))));
if(dis>t)break;
ans.pb(dis);
if(ans.size()==k)return 1;
it++;
}
C.insert({A[r].S,A[r].F});
r++;
}
C.erase({A[i].S,A[i].F});
}
return 0;
}
int32_t main(){
fast_io
cin>>n>>k;
for1(n){
int x,y;cin>>x>>y;
A[i]={x+y,x-y};
}
sort(A+1,A+n+1);
ll l=0,r=r=mod*4;
while(r-l!=1){
ll mid=(l+r)>>1;
if(check(mid)==0)l=mid;
else r=mid;
ans.clear();
}
check(l);
sort(all(ans));
for(int x:ans)cout<<x<<" ";cout<<endl;
for1(k-ans.size())cout<<l+1<<endl;
}
| # | 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... |