답안 #797063

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
797063 2023-07-29T05:36:09 Z vjudge1 Road Construction (JOI21_road_construction) C++17
12 / 100
86 ms 7560 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

ll dist(pair<ll, ll> a, pair<ll, ll> b) {
    return abs(a.first - b.first) + abs(a.second - b.second);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> p(n);
    for(int i = 0; i < n; i++) 
        cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());
    
    if(n <= 1000) {
        vector<ll> v;
        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) {
                v.push_back(dist(p[i], p[j]));
            }
        }    
        sort(v.begin(), v.end());
        for(int i = 0; i < k; i++) cout << v[i] << '\n';
        return 0;
    } 
    vector<ll> v;
    for(int i = 0; i < n - 1; i++) 
        v.push_back(dist(p[i], p[i + 1]));
    sort(v.begin(), v.end());
    for(int i = 0; i < k; i++) cout << v[i] << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 6840 KB Output is correct
2 Correct 52 ms 6928 KB Output is correct
3 Correct 32 ms 4976 KB Output is correct
4 Correct 32 ms 5064 KB Output is correct
5 Correct 47 ms 5812 KB Output is correct
6 Correct 16 ms 4552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 7560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 6396 KB Output is correct
2 Correct 77 ms 6412 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 51 ms 6404 KB Output is correct
5 Correct 67 ms 6408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 6396 KB Output is correct
2 Correct 77 ms 6412 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 51 ms 6404 KB Output is correct
5 Correct 67 ms 6408 KB Output is correct
6 Incorrect 76 ms 6404 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 6840 KB Output is correct
2 Correct 52 ms 6928 KB Output is correct
3 Correct 32 ms 4976 KB Output is correct
4 Correct 32 ms 5064 KB Output is correct
5 Correct 47 ms 5812 KB Output is correct
6 Correct 16 ms 4552 KB Output is correct
7 Runtime error 39 ms 6544 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 6840 KB Output is correct
2 Correct 52 ms 6928 KB Output is correct
3 Correct 32 ms 4976 KB Output is correct
4 Correct 32 ms 5064 KB Output is correct
5 Correct 47 ms 5812 KB Output is correct
6 Correct 16 ms 4552 KB Output is correct
7 Incorrect 86 ms 7560 KB Output isn't correct
8 Halted 0 ms 0 KB -