#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();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
6892 KB |
Output is correct |
2 |
Correct |
64 ms |
7028 KB |
Output is correct |
3 |
Correct |
51 ms |
5112 KB |
Output is correct |
4 |
Correct |
54 ms |
5056 KB |
Output is correct |
5 |
Correct |
68 ms |
5940 KB |
Output is correct |
6 |
Correct |
11 ms |
5320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
208 ms |
10664 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
209 ms |
12452 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
209 ms |
12452 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
6892 KB |
Output is correct |
2 |
Correct |
64 ms |
7028 KB |
Output is correct |
3 |
Correct |
51 ms |
5112 KB |
Output is correct |
4 |
Correct |
54 ms |
5056 KB |
Output is correct |
5 |
Correct |
68 ms |
5940 KB |
Output is correct |
6 |
Correct |
11 ms |
5320 KB |
Output is correct |
7 |
Incorrect |
104 ms |
6368 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
6892 KB |
Output is correct |
2 |
Correct |
64 ms |
7028 KB |
Output is correct |
3 |
Correct |
51 ms |
5112 KB |
Output is correct |
4 |
Correct |
54 ms |
5056 KB |
Output is correct |
5 |
Correct |
68 ms |
5940 KB |
Output is correct |
6 |
Correct |
11 ms |
5320 KB |
Output is correct |
7 |
Incorrect |
208 ms |
10664 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |