# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
682636 |
2023-01-16T16:18:45 Z |
as111 |
Karte (COCI18_karte) |
C++14 |
|
160 ms |
5340 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#define MAXN 500000
using namespace std;
int N, K;
vector<int> cards;
int sorted[MAXN + 5];
int f[MAXN + 5]; // # false below including itself
int main() {
cin >> N >> K;
for (int i = 0; i < N; i++) {
int c;
cin >> c;
cards.push_back(c);
}
sort(cards.begin(), cards.end());
/*
for (int i = 1; i <= N; i++) {
sorted[i] = cards[i - 1];
f[i] = f[i - 1];
if (sorted[i] > f[i - 1]) f[i]++;
}*/
bool works = true;
int start = 0;
int cnt = K;
for (int i = N; i >= 1; i--) {
if (cnt == 0) {
if (sorted[i] > K) works = false; // next card will be false no matter if it is placed before/after the K incorrect
start = i + 1;
break;
}
if (sorted[i] > cnt-1) { // count as false
cnt--;
}
}
if (cnt > 0)works = false;
if (works) {
for (int i = start; i <= N; i++) {
cout << sorted[i] << " ";
}
for (int i = 1; i < start; i++) {
cout << sorted[i] << " ";
}
}
else {
cout << -1;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
352 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 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 |
1 ms |
212 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 |
42 ms |
1468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
63 ms |
2416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
160 ms |
5340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |