# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1125540 | codexistent | Karte (COCI18_karte) | C11 | 0 ms | 0 KiB |
#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;
}