Submission #1066417

# Submission time Handle Problem Language Result Execution time Memory
1066417 2024-08-19T21:00:14 Z codexistent Karte (COCI18_karte) C++14
120 / 120
125 ms 7248 KB
#include <bits/stdc++.h>
using namespace std;
#define MAXN 500005
#define ll long long
#define FOR(i, a, b) for(ll i = a; i <= b; i++)

ll n, k, c[MAXN];

int main(){
    cin >> n >> k;
    FOR(i, 1, n) cin >> c[i];
    sort(c + 1, c + 1 + n);
    
    for(ll i = k; i >= 1; i--){
        if(c[n - (k - i)] < i){
            cout << -1 << endl;
            return 0;
        }
    }
    if(n - k >= 1 && c[n - k] > k) {
        cout << -1 << endl;
        return 0;
    }

    FOR(i, k + 1, n) cout << c[n - (i - 1)] << " ";
    for(ll i = k; i >= 1; i--) cout << c[n - (k - i)] << " ";
    cout << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 3544 KB Output is correct
2 Correct 21 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 3664 KB Output is correct
2 Correct 47 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 125 ms 6736 KB Output is correct
2 Correct 100 ms 7248 KB Output is correct