# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
682646 |
2023-01-16T16:34:22 Z |
as111 |
Karte (COCI18_karte) |
C++14 |
|
196 ms |
5228 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#define MAXN 500000
using namespace std;
int N, K;
vector<int> cards;
vector<int> temp;
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 = K; i > 0;i--) { // first K greatest cards need to be able to work
temp.push_back(cards.back());
cards.pop_back();
}
for (auto c : temp) {
cards.push_back(c);
}
int cnt = 0;
for (int i = N - 1; i >= 0;i--) {
if (cnt < cards[i]) {
cnt++;
}
}
if (cnt != K) {
cout << -1;
}
else {
for (auto c : cards) cout << c << " ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
368 KB |
Output is correct |
# |
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 |
Correct |
1 ms |
212 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 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
1528 KB |
Output is correct |
2 |
Correct |
33 ms |
1460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
82 ms |
2496 KB |
Output is correct |
2 |
Correct |
64 ms |
2340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
5228 KB |
Output is correct |
2 |
Correct |
158 ms |
2624 KB |
Output is correct |