Submission #57142

# Submission time Handle Problem Language Result Execution time Memory
57142 2018-07-14T06:55:02 Z polyfish Karte (COCI18_karte) C++14
0 / 120
1000 ms 8848 KB
//I love armpit fetish

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

const int MAX_N = 500002;

int n, k, a[MAX_N];

void enter() {
	cin >> n >> k;
	for (int i=1; i<=n; ++i)
		cin >> a[i];
}

bool check() {
	int false_claim = 0;
	PR(a, n);
	for (int i=n; i>=1; --i) {
		if (a[i]>false_claim) {
			++false_claim;
		}
	}
	return false_claim == k;
}

void solve() {
	sort(a+1, a+n+1);
	reverse(a+n-k+1, a+n+1);
	if (check()) {
		for (int i=1; i<=n; ++i)
			cout << a[i] << ' ';
	}
	else {
		cout << -1;
	}
}

int main() {
	//#define OFFLINE_JUDGE doraemon
	#ifdef OFFLINE_JUDGE
		freopen(FILE_NAME".inp", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);
	enter();
	solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 248 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 360 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 472 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 668 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 668 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 712 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 712 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 391 ms 2720 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 722 ms 5520 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 8848 KB Time limit exceeded
2 Halted 0 ms 0 KB -