Submission #237553

# Submission time Handle Problem Language Result Execution time Memory
237553 2020-06-07T09:45:14 Z NONAME Karte (COCI18_karte) C++17
120 / 120
130 ms 7160 KB
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define el '\n'
using namespace std;

typedef long long ll;
const int N = 5e5 + 10;

int n, k, a[N], b[N], cnt;

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

    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    sort(a, a + n);

    for (int i = 0; i < n; ++i)
        b[i] = a[(i + n - k) % n];

    for (int i = 0; i < n; ++i)
        if (b[i] > cnt)
            cnt++;

    if (cnt != k) {
        cout << -1;
        return 0;
    }

    for (int i = n - 1; i >= 0; --i)
        cout << b[i] << ' ';
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 436 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1656 KB Output is correct
2 Correct 22 ms 1384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 2936 KB Output is correct
2 Correct 39 ms 3192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 130 ms 6776 KB Output is correct
2 Correct 87 ms 7160 KB Output is correct