#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
#define int i64
#define vi vector<int>
#define vvi vector<vi>
#define vb vector<bool>
#define pii pair<int, int>
#define fi first
#define se second
#define sz(x) (int)(x).size()
// büyüklerin yanlış olması daha olası
//yanlışlar kendi arasında büyükten küçük/adcajentlar swaplayabilirim (1 0), k tane yanlışım olmalı
inline void solve(){
int n, k;
cin >> n >> k;
vi a(n);
for(int &i : a){
cin >> i;
}
sort(a.begin(), a.end(), greater<int>());
reverse(a.begin(), a.begin() + k);
int f = 0;
bool can = true;
for(int i = 0; i < k; i++){ // k yanlışın hepsini sola doğru komşularıyla swaplayarak başa getirdim. i'de yanlış olan i - 1 de de yanlış olur, i - 1 de deoğru olan i'de de doğru olur
if(f >= a[i]){
can = false;
break;
}
f++;
}
for(int i = k; i < n; i++){
if(a[i] > f){
can = false;
break;
}
}
if(can){
for(int &i : a){
cout << i << " ";
}
cout << "\n";
}
else{
cout << "-1\n";
}
return;
}
signed main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int t = 1;
//cin >> t;
while(t--){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |