Submission #682643

# Submission time Handle Problem Language Result Execution time Memory
682643 2023-01-16T16:28:44 Z as111 Karte (COCI18_karte) C++14
12 / 120
165 ms 3068 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 (int c : temp) {
		cards.push_back(c);
	}
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (cnt < cards[i]) {
			cnt++;
		}
	}
	if (cnt != K) {
		cout << -1;
	}
	else {
		for (int c : cards) cout << c << " ";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 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 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 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 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 1492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 1980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 165 ms 3068 KB Output isn't correct
2 Halted 0 ms 0 KB -