#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll dist(pair<int, int> a, pair<int, int> b) {
return abs(a.first - b.first) + abs(a.second - b.second);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n, k;
cin >> n >> k;
vector<pair<int, int>> p(n);
for(int i = 0; i < n; i++)
cin >> p[i].first >> p[i].second;
sort(p.begin(), p.end());
if(n <= 1000) {
vector<int> v;
for(int i = 0; i < n; i++) {
for(int j = i + 1; j < n; j++) {
v.push_back(dist(p[i], p[j]));
}
}
sort(v.begin(), v.end());
for(int i = 0; i < k; i++) cout << v[i] << '\n';
return 0;
}
vector<int> v;
for(int i = 0; i < n - 1; i++)
v.push_back(dist(p[i], p[i + 1]));
sort(v.begin(), v.end());
for(int i = 0; i < k; i++) cout << v[i] << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
51 ms |
4964 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
77 ms |
4572 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
3420 KB |
Output is correct |
2 |
Correct |
77 ms |
3424 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
3420 KB |
Output is correct |
2 |
Correct |
77 ms |
3424 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
51 ms |
4964 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
51 ms |
4964 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |