Submission #734609

# Submission time Handle Problem Language Result Execution time Memory
734609 2023-05-02T17:14:06 Z JellyTheOctopus Karte (COCI18_karte) C++17
24 / 120
167 ms 2260 KB
#include <bits/stdc++.h>
using namespace std;

int N, K;
vector<int> arr;

int check() {
	int numLies = 0;
	for (int i = 0; i < N; i++) {
		if (numLies < arr[i]) {
			numLies++;
		}
	}
	return numLies;
}

int main() {
	cin >> N >> K;
	arr.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> arr[i];
	}	
	sort(arr.begin(), arr.end(), greater<int>());
	int numLies = check();
	if (numLies > K) {
		cout << -1 << "\n";
	} 
	else {
		rotate(arr.begin(), arr.begin()+(K-numLies), arr.end());
		
		numLies = check();
		if (numLies != K) {
			cout << -1 << "\n";
		}
		else {
			for (int i = N-1; i >= 0; i--) {
				cout << arr[i] << " ";
			} cout << "\n";
		}
	}
}
# 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 0 ms 212 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 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 36 ms 688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 1076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 167 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -