Submission #47106

# Submission time Handle Problem Language Result Execution time Memory
47106 2018-04-27T15:45:57 Z Bruteforceman Karte (COCI18_karte) C++11
120 / 120
150 ms 9368 KB
#include "bits/stdc++.h"
using namespace std;
int a[500010];
int b[500010];

int main(int argc, char const *argv[])
{
	ios_base :: sync_with_stdio (false);
	cin.tie (0);

	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	k = n - k;
	for(int i = 0; i < n; i++) {
		b[i] = a[(i + k) % n];
	}
	int bad = 0;
	int good = 0;
	for(int i = 0; i < n; i++) {
		if(bad >= b[i]) {
			++good;
		} else {
			++bad;
		}
	}
	reverse(b, b + n);
	if(good == k) {
		for(int i = 0; i < n; i++) {
			cout << b[i] << " ";
		}
		cout << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 412 KB Output is correct
2 Correct 2 ms 540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 540 KB Output is correct
2 Correct 2 ms 540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 616 KB Output is correct
2 Correct 2 ms 616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 680 KB Output is correct
2 Correct 2 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 700 KB Output is correct
2 Correct 2 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 744 KB Output is correct
2 Correct 2 ms 872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2052 KB Output is correct
2 Correct 22 ms 2060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 3964 KB Output is correct
2 Correct 41 ms 4080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 150 ms 8984 KB Output is correct
2 Correct 95 ms 9368 KB Output is correct