제출 #861842

#제출 시각아이디문제언어결과실행 시간메모리
861842maks007Zalmoxis (BOI18_zalmoxis)C++14
0 / 100
138 ms10540 KiB
#include "bits/stdc++.h"

using namespace std;

signed main () {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	vector <int> a, b;
	for(int i = 0; i < n; i ++) {
		int x;
		cin >> x;
		a.push_back(x);
	}
	b = a;
	sort(a.rbegin(), a.rend());
	int which = -1;
	while(a.size() != 1) {
		int val1 = a.back();
		a.pop_back();
		if(val1 == a.back()) {
			a.pop_back();
			a.push_back(val1+1);
		}else {
			k --;
			which = val1;
			if(which != -1) break;
			a.push_back(val1+1);
		}
	}
	assert(which != -1);
	for(auto i : b) cout << i << " ";
	cout << which;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...