# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
867485 | pizzamoeger | Zalmoxis (BOI18_zalmoxis) | C++14 | 117 ms | 25900 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main () {
cin.tie(0);
ios_base::sync_with_stdio(0);
int n, k; cin >> n >> k;
vector<int> S (n);
for (int i = 0; i < n; i++) cin >> S[i];
n++;
S.push_back(30);
stack<int> nums;
vector<pair<int,int>> inserts;
int i = 0;
while (i < n) {
int cur = S[i];
while (!nums.empty()) {
int top = nums.top();
//cerr << cur << " " << top << " " << i << "\n";
if (cur == top) {
cur++;
nums.pop();
} else if (cur > top) {
inserts.push_back({i, top});
cur = top+1;
nums.pop();
i--;
} else {
nums.push(cur);
break;
}
}
if (nums.empty()) nums.push(cur);
i++;
}
if (!nums.empty() && nums.top() != 31) inserts.push_back({n, nums.top()});
int left = k-inserts.size();
int j = 0;
while (left > 0) {
while (inserts[j].second == 0) j++;
inserts[j].second--;
inserts.push_back(inserts[j]);
left--;
}
sort(inserts.begin(), inserts.end());
j = 0;
for (int i = 0; i < n; i++) {
while (j < inserts.size() && i == inserts[j].first) {
int cnt = inserts[j].second;
cout << cnt << " ";
j++;
}
if (i != n-1) cout << S[i] << " ";
}
while (j < inserts.size() && n == inserts[j].first) {
assert(false);
int cnt = inserts[j].second;
cout << cnt << " ";
j++;
}
cout << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |