# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
91038 |
2018-12-25T20:32:01 Z |
sjhuang26 |
Karte (COCI18_karte) |
C++14 |
|
211 ms |
13928 KB |
#include<iostream>
#include<algorithm>
int N,K,a[500000],ans[500000];
using namespace std;
int main(){
cin>>N>>K;
for(int i=0;i<N;++i)cin>>a[i];
sort(a,a+N);
int b=0;
while(b!=N&&a[b]<=K)++b;
if(N-b>K){
cout<<-1<<'\n';
}else{
int j=N-1,k=K;
for(int i=N-K;i<N;++i){
if(a[j]<k){
cout<<-1<<'\n';return 0;
}else{
ans[i]=a[j];
--j;--k;
}
}
for(int i=0;i<N-K;++i){
ans[i]=a[j];
--j;
}
for(int i=0;i<N;++i){
cout<<ans[i];if(i!=N-1)cout<<' ';
}
cout<<'\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
524 KB |
Output is correct |
2 |
Correct |
2 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
640 KB |
Output is correct |
2 |
Correct |
2 ms |
752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
756 KB |
Output is correct |
2 |
Correct |
2 ms |
892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
896 KB |
Output is correct |
2 |
Correct |
2 ms |
920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
944 KB |
Output is correct |
2 |
Correct |
2 ms |
960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
968 KB |
Output is correct |
2 |
Correct |
3 ms |
996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
2852 KB |
Output is correct |
2 |
Correct |
36 ms |
2852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
5912 KB |
Output is correct |
2 |
Correct |
70 ms |
5912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
211 ms |
13928 KB |
Output is correct |
2 |
Correct |
171 ms |
13928 KB |
Output is correct |