Submission #735638

# Submission time Handle Problem Language Result Execution time Memory
735638 2023-05-04T12:24:00 Z tvladm2009 Karte (COCI18_karte) C++14
12 / 120
89 ms 14004 KB
#include <bits/stdc++.h>
#define int ll

using namespace std;

typedef long long ll;

const int N_MAX = 5e5;

int A[N_MAX + 2];
int B[N_MAX + 2];
int C[N_MAX + 2];

int N, K;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> N >> K;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }
    sort(A + 1, A + N + 1);
    for (int i = 1; i <= N - K; i++) {
        B[i] = A[K + i];
    }
    sort(A + 1, A + K + 1);
    sort(B + 1, B + N - K + 1);
    for (int i = 1; i <= N - K; i++) {
        C[i] = B[i];
    }
    for (int i = 1; i <= K; i++) {
        C[N - K + i] = A[i];
    }

    int cnt = 0;
    for (int i = N; i >= 1; i--) {
        if (C[i] > cnt) {
            cnt++;
        }
    }
    if (cnt != K) {
        cout << "-1\n";
    } else {
        for (int i = 1; i <= N; i++) {
            cout << C[i] << " ";
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 2380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 5284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 14004 KB Output isn't correct
2 Halted 0 ms 0 KB -