This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
void solve(){
int n,k;
cin >> n >> k;
vector<int> v(n);
for(int i = 0; i < n; i++){
cin >> v[i];
}
sort(rall(v));
for(int i = 0; i < k; i++){
if(v[i] < k - i){
cout << -1 << endl;
return;
}
}
vector<int> ans;
for(int i = k - 1; i >= 0; i--){
ans.pb(v[i]);
}
for(int i = k; i < n; i++){
if(v[i] > k){
cout << -1 << endl;
return;
}
ans.pb(v[i]);
}
reverse(all(ans));
for(int x : ans){
cout << x << ' ';
}
}
signed main(){
ios::sync_with_stdio(0);
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... |