# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
735644 |
2023-05-04T12:30:06 Z |
tvladm2009 |
Karte (COCI18_karte) |
C++17 |
|
81 ms |
5984 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 <= N - K; i++) {
B[i] = A[K + i];
}
sort(A + 1, A + K + 1);
reverse(A + 1, A + K + 1);
sort(B + 1, B + N - K + 1);
reverse(B + 1, B + N - K + 1);
for (int i = 1; i <= K; i++) {
C[i] = A[i];
}
for (int i = 1; i <= N - K; i++) {
C[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 |
1 ms |
340 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 |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
1364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
2504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
81 ms |
5984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |