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;
int main(void){
int n,k;
vector<int>a;
cin >> n >> k;
a.push_back(-1);
for(int i=1;i<=n;i++){
int c; cin >> c; a.push_back(c);
}
sort(a.begin(),a.end());
for(int i=1;i<=n-k;i++){
if(a[i]>k){
cout << -1;
return 0;
}
}
for(int i=1;i<=k;i++){
if(a[i+n-k]<i){
cout << -1;
return 0;
}
}
for(int i=n-k;i>=1;i--){
cout << a[i] << " ";
}
for(int i=k;i>=1;i--){
cout << a[i+n-k] << " ";
}
}
# | 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... |