#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<int> arr;
bool check() {
int numFalse = 0;
for (int i = 0; i < N; i++) {
if (arr[i] > numFalse) {
numFalse++;
}
}
if (numFalse == K) {
return true;
}
return false;
}
int main() {
cin >> N >> K;
arr.resize(N);
for (int i = 0; i < N; i++) {
cin >> arr[i];
}
sort(arr.begin(), arr.end());
rotate(arr.begin(), arr.begin()+(N-K), arr.end());
if (check()) {
for (int i = N-1; i >= 0; i--) {
cout << arr[i] << " ";
} cout << "\n";
}
else {
cout << -1 << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
1788 KB |
Output is correct |
2 |
Correct |
31 ms |
1204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
3252 KB |
Output is correct |
2 |
Correct |
61 ms |
2204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
197 ms |
7748 KB |
Output is correct |
2 |
Correct |
153 ms |
5176 KB |
Output is correct |