Submission #308655

# Submission time Handle Problem Language Result Execution time Memory
308655 2020-10-01T16:27:30 Z shrek12357 Karte (COCI18_karte) C++14
108 / 120
379 ms 7412 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include <stack>
using namespace std;
#define ll long long
//cin.tie(0);
//ios_base::sync_with_stdio(0);

bool comp(int a, int b) {
	return  a > b;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> nums;
	//int counter = 0;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		//if (temp == 0) {
		//	counter++;
		//	continue;
		//}
		nums.push_back(temp);
	}
	sort(nums.begin(), nums.end());
	vector<int> temp = nums;
	sort(temp.begin(), temp.end(), comp);
	for (int i = n - k; i < n; i++) {
		if (nums[i] <= i - (n - k)) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n - k; i++) {
		if (nums[i] > n - i) {
			cout << -1 << endl;
			return 0;
		}
	}
//	for (int i = 0; i < counter; i++) {
	//	cout << 0 << " ";
//	}
	for (int i = n - k - 1; i >= 0; i--) {
		cout << nums[i] << " ";
	}
	for (int i = n - 1; i >= n - k; i--) {
		cout << nums[i] << " ";
	}
	cout << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 2032 KB Output is correct
2 Correct 69 ms 1904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 153 ms 3308 KB Output is correct
2 Correct 133 ms 3180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 379 ms 7140 KB Output is correct
2 Correct 329 ms 7412 KB Output is correct