#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ar array
const int INF = 1e15;
const int MOD = 1e9+7;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, c; cin>>n>>c;
vector<int> a(n);
for (int &i : a) cin>>i;
sort(a.begin(), a.end());
vector<int> ans;
for (int i = 0; i < n-c; i++) {
ans.push_back(a[i]);
}
for (int i = n-1; i >= n-c; --i) {
ans.push_back(a[i]);
}
int liars = 0;
for (int i = n-1; i >= 0; --i) {
if (liars < ans[i]) liars++;
}
if (liars != c) {
cout<<-1<<"\n";
return 0;
}
for (int i : ans) cout<<i<<" ";
cout<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
3304 KB |
Output is correct |
2 |
Correct |
19 ms |
2924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
5860 KB |
Output is correct |
2 |
Correct |
38 ms |
5224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
13884 KB |
Output is correct |
2 |
Correct |
85 ms |
11492 KB |
Output is correct |