#include <bits/stdc++.h>
using namespace std;
void solve() {
ifstream cin ("zalmoxis.in");
ofstream cout ("zalmoxis.out");
int n, k;
cin >> n >> k;
vector<int> st = {(int) 1e9};
vector<int> a(n), ans;
int done = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i];
if (a[i] == st.back()) {
st.push_back(a[i]);
while (st.size() > 1 && st.back() == st[st.size() - 2]) {
st.pop_back();
st.back()++;
}
} else if (a[i] > st.back()) {
while (a[i] >= st.back()) {
ans.push_back(st.back());
++done;
st.back()++;
while (st.size() > 1 && st.back() == st[st.size() - 2]) {
st.pop_back();
st.back()++;
}
}
--done;
ans.pop_back();
} else {
st.push_back(a[i]);
}
ans.push_back(a[i]);
}
while (st.size() != 2) {
ans.push_back(st.back());
st.push_back(st.back());
++done;
while (st.size() > 1 && st.back() == st[st.size() - 2]) {
st.pop_back();
st.back()++;
}
}
for (int it = st[1]; it < st[1] + k - done; ++it) {
ans.push_back(it);
}
for (int x : ans) cout << x << ' ';
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
362 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Runtime error |
337 ms |
262148 KB |
Execution killed with signal 9 |
3 |
Runtime error |
333 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Runtime error |
326 ms |
262144 KB |
Execution killed with signal 9 |
5 |
Runtime error |
297 ms |
262144 KB |
Execution killed with signal 9 |
6 |
Runtime error |
303 ms |
262144 KB |
Execution killed with signal 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
322 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Runtime error |
302 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Runtime error |
302 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Runtime error |
289 ms |
262144 KB |
Execution killed with signal 9 |
5 |
Runtime error |
294 ms |
262144 KB |
Execution killed with signal 9 |
6 |
Runtime error |
306 ms |
262144 KB |
Execution killed with signal 9 |
7 |
Runtime error |
297 ms |
262144 KB |
Execution killed with signal 9 |
8 |
Runtime error |
322 ms |
262144 KB |
Execution killed with signal 9 |
9 |
Runtime error |
307 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Runtime error |
308 ms |
262144 KB |
Execution killed with signal 9 |
11 |
Runtime error |
315 ms |
262144 KB |
Execution killed with signal 9 |
12 |
Runtime error |
322 ms |
262144 KB |
Execution killed with signal 9 |
13 |
Runtime error |
303 ms |
262144 KB |
Execution killed with signal 9 |
14 |
Runtime error |
330 ms |
262144 KB |
Execution killed with signal 9 |