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 n,k,i,x;
vector <int> v;
bool proveri(){
int br=0;
for(i=v.size()-1;i>=0;i--){
if(v[i]>br) br++;
}
return br==k;
}
int main(){
std::ios_base::sync_with_stdio(0);
cin>>n>>k;
for(i=0;i<n;i++){
cin>>x;
v.push_back(x);
}
sort(v.begin(),v.end());
reverse(v.end()-k,v.end());
if(!proveri()) cout<<-1<<endl;
else{
for(i=0;i<n;i++) cout<<v[i]<<" ";
}
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... |