이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#ifdef DEBUG
#include "debug.hpp"
#else
#pragma GCC optimize("Ofast")
#define trace(...)
#include <bits/stdc++.h>
#define endl '\n'
#endif
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
if (k == 1) {
int rem = 1 << 30;
for (int i = 0; i < n; ++i) {
rem -= 1 << a[i];
}
int lost = __builtin_ctz(rem);
stack<int> st;
int i;
for (i = 0; i < n; ++i) {
if (st.empty() || a[i] < st.top()) {
st.push(a[i]);
} else if (a[i] == st.top()) {
int h = a[i];
while (!st.empty() && h == st.top()) {
++h;
st.pop();
}
st.push(h);
} else {
break;
}
}
a.insert(a.begin() + i, lost);
for (int j = 0; j < n + k; ++j) {
cout << a[j] << ' ';
}
} else {
assert(false);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |