Submission #447901

# Submission time Handle Problem Language Result Execution time Memory
447901 2021-07-28T05:14:47 Z blue Road Construction (JOI21_road_construction) C++17
5 / 100
2323 ms 2097156 KB
#include <iostream>
#include <algorithm>
using namespace std;

long long abs_diff(long long a, long long b)
{
    return max(a-b, b-a);
}

int main()
{
    int N, K;
    cin >> N >> K;

    long long X[N], Y[N];
    for(int i = 0; i < N; i++) cin >> X[i] >> Y[i];


    vector<long long> res;
    for(int i = 0; i < N; i++)
        for(int j = i+1; j < N; j++)
            res.push_back(abs_diff(X[i], X[j]) + abs_diff(Y[i], Y[j]));

    sort(res.begin(), res.end());

    while(res.size() > K) res.pop_back();

    for(long long r:res) cout << r << ' ';
    cout << '\n';
}

Compilation message

road_construction.cpp: In function 'int main()':
road_construction.cpp:26:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     while(res.size() > K) res.pop_back();
      |           ~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 81 ms 6896 KB Output is correct
2 Correct 87 ms 6888 KB Output is correct
3 Correct 60 ms 5200 KB Output is correct
4 Correct 55 ms 4944 KB Output is correct
5 Correct 76 ms 5752 KB Output is correct
6 Correct 26 ms 4436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2323 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2153 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2153 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 81 ms 6896 KB Output is correct
2 Correct 87 ms 6888 KB Output is correct
3 Correct 60 ms 5200 KB Output is correct
4 Correct 55 ms 4944 KB Output is correct
5 Correct 76 ms 5752 KB Output is correct
6 Correct 26 ms 4436 KB Output is correct
7 Runtime error 1915 ms 2097156 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 81 ms 6896 KB Output is correct
2 Correct 87 ms 6888 KB Output is correct
3 Correct 60 ms 5200 KB Output is correct
4 Correct 55 ms 4944 KB Output is correct
5 Correct 76 ms 5752 KB Output is correct
6 Correct 26 ms 4436 KB Output is correct
7 Runtime error 2323 ms 2097156 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -