Submission #1066416

# Submission time Handle Problem Language Result Execution time Memory
1066416 2024-08-19T20:59:33 Z codexistent Karte (COCI18_karte) C++14
84 / 120
1 ms 604 KB
#include <bits/stdc++.h>
using namespace std;
#define MAXN 2005
#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 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 0 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 448 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 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -