Submission #448057

# Submission time Handle Problem Language Result Execution time Memory
448057 2021-07-28T16:48:31 Z sidpark1 Karte (COCI18_karte) C++17
96 / 120
28 ms 2540 KB
#include <bits/stdc++.h>
using namespace std;

int64_t n, k, a[100000+1], temp = 0;
vector<int64_t> ans;
bool possible = true;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for(int64_t i=0; i<n; i++) {
        cin >> a[i];
    }
    sort(a,a+n);
    for(int64_t i=n-k; i<n; i++) {
        ans.push_back(a[i]);
    }
    for(int64_t i=0; i<n-k; i++) {
        ans.push_back(a[i]);
    }
    for(int64_t i=0; i<n; i++) {
        if(i < k) {
            if(ans[i] <= temp) {
                possible = false;
               // break;
            }
            temp++;
        }
        else if(ans[i] > k) {
            possible = false;
          //  break;
        }
    }
    if(!possible) cout << "-1\n";
    else {
        reverse(ans.begin(), ans.end());
        for(auto i : ans) {
            cout << i << " ";
        }
        cout << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2540 KB Output is correct
2 Correct 19 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 1228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -