Submission #589733

# Submission time Handle Problem Language Result Execution time Memory
589733 2022-07-05T08:14:37 Z Valaki2 Road Construction (JOI21_road_construction) C++14
5 / 100
68 ms 8452 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second

inline int dist(pii a, pii b) {
    return abs(a.fi - b.fi) + abs(a.se - b.se);
}

int n, k;
vector<pii > points;

void solve() {
    cin >> n >> k;
    points.assign(n, mp(0, 0));
    for(int i = 0; i < n; i++) {
        cin >> points[i].fi >> points[i].se;
    }
    vector<int > v(n * (n - 1) / 2);
    int idx = -1;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            idx++;
            v[idx] = dist(points[i], points[j]);
        }
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < k; i++) {
        cout << v[i] << "\n";
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 68 ms 6820 KB Output is correct
2 Correct 58 ms 6732 KB Output is correct
3 Correct 37 ms 4844 KB Output is correct
4 Correct 36 ms 4976 KB Output is correct
5 Correct 54 ms 5648 KB Output is correct
6 Correct 19 ms 4260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 50 ms 8452 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 57 ms 8452 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 57 ms 8452 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 68 ms 6820 KB Output is correct
2 Correct 58 ms 6732 KB Output is correct
3 Correct 37 ms 4844 KB Output is correct
4 Correct 36 ms 4976 KB Output is correct
5 Correct 54 ms 5648 KB Output is correct
6 Correct 19 ms 4260 KB Output is correct
7 Runtime error 26 ms 3684 KB Execution killed with signal 6
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 68 ms 6820 KB Output is correct
2 Correct 58 ms 6732 KB Output is correct
3 Correct 37 ms 4844 KB Output is correct
4 Correct 36 ms 4976 KB Output is correct
5 Correct 54 ms 5648 KB Output is correct
6 Correct 19 ms 4260 KB Output is correct
7 Runtime error 50 ms 8452 KB Execution killed with signal 6
8 Halted 0 ms 0 KB -