Submission #944947

# Submission time Handle Problem Language Result Execution time Memory
944947 2024-03-13T08:42:25 Z bngybongybrd Road Construction (JOI21_road_construction) C++17
5 / 100
10000 ms 1078832 KB
#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
1 Correct 441 ms 38336 KB Output is correct
2 Correct 448 ms 38192 KB Output is correct
3 Correct 198 ms 20688 KB Output is correct
4 Correct 206 ms 20672 KB Output is correct
5 Correct 442 ms 37052 KB Output is correct
6 Correct 407 ms 35876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 10046 ms 1041900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10056 ms 1028460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10056 ms 1028460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 441 ms 38336 KB Output is correct
2 Correct 448 ms 38192 KB Output is correct
3 Correct 198 ms 20688 KB Output is correct
4 Correct 206 ms 20672 KB Output is correct
5 Correct 442 ms 37052 KB Output is correct
6 Correct 407 ms 35876 KB Output is correct
7 Execution timed out 10130 ms 1078832 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 441 ms 38336 KB Output is correct
2 Correct 448 ms 38192 KB Output is correct
3 Correct 198 ms 20688 KB Output is correct
4 Correct 206 ms 20672 KB Output is correct
5 Correct 442 ms 37052 KB Output is correct
6 Correct 407 ms 35876 KB Output is correct
7 Execution timed out 10046 ms 1041900 KB Time limit exceeded
8 Halted 0 ms 0 KB -