#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, k;
vector<pair<int, int>> coor;
void brute(){
vector<int> ans;
for(int i = 0; i<n-1; i++){
for(int j = i+1; j<n; j++){
ans.push_back(abs(coor.at(j).first - coor.at(i).first) + abs(coor.at(j).second - coor.at(i).second));
}
}
sort(ans.begin(), ans.end());
for(int i = 0; i<k; i++){
cout << ans.at(i) << "\n";
}
return;
}
void second(){
vector<int> ans;
for(int i = 0; i<n-1; i++){
for(int j = i+1; j<n; j++){
ans.push_back(abs(coor.at(i).first - coor.at(j).first));
}
}
sort(ans.begin(), ans.end());
for(int i = 0; i<k; i++){
cout << ans.at(i) << "\n";
}
return;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>k;
bool two = true;
for(int i = 0; i<n; i++){
int x, y;
cin>>x>>y;
coor.push_back({x, y});
if(y != 0){
two = false;
}
}
sort(coor.begin(), coor.end());
if(two){
second();
return 0;
}else{
brute();
return 0;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
7116 KB |
Output is correct |
2 |
Correct |
52 ms |
6916 KB |
Output is correct |
3 |
Correct |
33 ms |
5072 KB |
Output is correct |
4 |
Correct |
32 ms |
5080 KB |
Output is correct |
5 |
Correct |
47 ms |
5920 KB |
Output is correct |
6 |
Correct |
16 ms |
6356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1489 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1275 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1275 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
7116 KB |
Output is correct |
2 |
Correct |
52 ms |
6916 KB |
Output is correct |
3 |
Correct |
33 ms |
5072 KB |
Output is correct |
4 |
Correct |
32 ms |
5080 KB |
Output is correct |
5 |
Correct |
47 ms |
5920 KB |
Output is correct |
6 |
Correct |
16 ms |
6356 KB |
Output is correct |
7 |
Runtime error |
1234 ms |
2097152 KB |
Execution killed with signal 9 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
7116 KB |
Output is correct |
2 |
Correct |
52 ms |
6916 KB |
Output is correct |
3 |
Correct |
33 ms |
5072 KB |
Output is correct |
4 |
Correct |
32 ms |
5080 KB |
Output is correct |
5 |
Correct |
47 ms |
5920 KB |
Output is correct |
6 |
Correct |
16 ms |
6356 KB |
Output is correct |
7 |
Runtime error |
1489 ms |
2097152 KB |
Execution killed with signal 9 |
8 |
Halted |
0 ms |
0 KB |
- |