# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
735657 |
2023-05-04T12:36:44 Z |
tvladm2009 |
Karte (COCI18_karte) |
C++17 |
|
119 ms |
7304 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N_MAX = 5e5;
int A[N_MAX + 2];
int B[N_MAX + 2];
int C[N_MAX + 2];
int N, K;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N >> K;
for (int i = 1; i <= N; i++) {
cin >> A[i];
}
sort(A + 1, A + N + 1);
for (int i = 1; i <= K; i++) {
B[i] = A[N - K + i];
}
sort(A + 1, A + N - K + 1);
reverse(A + 1, A + N - K + 1);
sort(B + 1, B + K + 1);
reverse(B + 1, B + K + 1);
for (int i = 1; i <= N - K; i++) {
C[i] = A[i];
}
for (int i = 1; i <= K; i++) {
C[N - K + i] = B[i];
}
int cnt = 0;
for (int i = N; i >= 1; i--) {
if (C[i] > cnt) {
cnt++;
}
}
if (cnt != K) {
cout << "-1\n";
} else {
for (int i = 1; i <= N; i++) {
cout << C[i] << " ";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1752 KB |
Output is correct |
2 |
Correct |
18 ms |
1700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
2936 KB |
Output is correct |
2 |
Correct |
44 ms |
3064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
6848 KB |
Output is correct |
2 |
Correct |
93 ms |
7304 KB |
Output is correct |