#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<int> arr;
int check() {
int numLies = 0;
for (int i = 0; i < N; i++) {
if (numLies < arr[i]) {
numLies++;
}
}
return numLies;
}
int main() {
cin >> N >> K;
arr.resize(N);
for (int i = 0; i < N; i++) {
cin >> arr[i];
}
sort(arr.begin(), arr.end(), greater<int>());
int numLies = check();
if (numLies > K) {
cout << -1 << "\n";
}
else {
rotate(arr.begin(), arr.begin()+(K-numLies), arr.end());
numLies = check();
if (numLies != K) {
cout << -1 << "\n";
}
else {
for (int i = 0; i < N; i++) {
cout << arr[i] << " ";
} cout << "\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 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
304 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
33 ms |
1196 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
69 ms |
2264 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
170 ms |
5180 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |