# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
448053 |
2021-07-28T16:43:33 Z |
sidpark1 |
Karte (COCI18_karte) |
C++17 |
|
36 ms |
3104 KB |
#include <bits/stdc++.h>
using namespace std;
int64_t n, k, a[100000+1], temp = 0;
vector<int64_t> ans;
bool possible = true;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for(int64_t i=0; i<n; i++) {
cin >> a[i];
}
sort(a,a+n);
for(int64_t i=n-k; i<n; i++) {
ans.push_back(a[i]);
}
for(int64_t i=0; i<n-k; i++) {
ans.push_back(a[i]);
}
for(int64_t i=0; i<n; i++) {
if(i < k and ans[i] <= temp) {
possible = false;
break;
}
else if(i < k) {
temp++;
}
else {
if(ans[i] > k) {
possible = false;
break;
}
}
}
if(!possible) cout << "-1\n";
else {
reverse(ans.begin(), ans.end());
for(auto i : ans) {
cout << i << " ";
}
cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
3104 KB |
Output is correct |
2 |
Correct |
19 ms |
2856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
1996 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
2232 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |