This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int,int>
typedef vector<int> vi;
#define iii tuple<int,int,int>
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef map<int,int> mii;
#ifndef debug
#define cerr if (0) cerr
#endif
int N, K;
vi X,Y;
int32_t main(){
cin>>N>>K;
for (int i=0; i<N; i++){
int a,b; cin>>a>>b;
X.emplace_back(a); Y.emplace_back(b);
}
priority_queue<int, vi, greater<int>> PQ;
if (N<=1000){
for (int i=0; i<N; i++){
for (int j=i+1; j<N; j++){
PQ.push(abs(X[i]-X[j])+abs(Y[i]-Y[j]));
//cout<<i<<" "<<j<<abs(X[i]-X[j])+abs(Y[i]-Y[j])<<"\n";
}
}
}else{
sort(X.begin(), X.end());
for (int i=1; i<N; i++){
PQ.push(abs(X[i]-X[i-1]));
}
}
for (int i=0; i<K; i++){
cout<<PQ.top()<<"\n";
PQ.pop();
}
}
# | 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... |