Submission #736648

# Submission time Handle Problem Language Result Execution time Memory
736648 2023-05-06T04:12:57 Z JellyTheOctopus Karte (COCI18_karte) C++17
120 / 120
197 ms 7748 KB
#include <bits/stdc++.h>
using namespace std;

int N, K;
vector<int> arr;

bool check() {
	int numFalse = 0;
	for (int i = 0; i < N; i++) {
		if (arr[i] > numFalse) {
			numFalse++;
		}
	}
	if (numFalse == K) {
		return true;
	}
	return false;
}

int main() {
	cin >> N >> K;
	arr.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> arr[i];
	}
	sort(arr.begin(), arr.end());
	rotate(arr.begin(), arr.begin()+(N-K), arr.end());
	if (check()) {
		for (int i = N-1; i >= 0; i--) {
			cout << arr[i] << " ";
		} cout << "\n";
	}
	else {
		cout << -1 << "\n";
	}
}
# 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 300 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 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 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 1788 KB Output is correct
2 Correct 31 ms 1204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 3252 KB Output is correct
2 Correct 61 ms 2204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 197 ms 7748 KB Output is correct
2 Correct 153 ms 5176 KB Output is correct