이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, k;
vector<pair<int, pair<int, int>>> towns;
map<pair<int, int>, int> check;
vector<int> cost;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
for(int i = 0; i < n; i++){
int x, y;
cin >> x >> y;
towns.push_back({i, {x, y}});
}
for(auto i: towns){
for(auto j: towns){
if(i.first == j.first) continue;
if(check.count({i.first, j.first}) == 1 || check.count({j.first, i.first}) == 1) continue;
int sum = 0;
sum += abs(i.second.first - j.second.first) + abs(i.second.second - j.second.second);
cost.push_back(sum);
check[{i.first, j.first}] = 1;
}
}
sort(cost.begin(), cost.end());
for(int i = 0; i < k; i++){
cout << cost.at(i) << "\n";
}
return 0;
}
# | 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... |