#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()) {
st.push(a[i]);
} else {
if (a[i] == st.top()) {
int k = a[i];
while (!st.empty() && k == st.top()) {
k = st.top() + 1;
st.pop();
}
st.push(k);
} else if (a[i] < st.top()) {
st.push(a[i]);
} 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 |
1 |
Correct |
171 ms |
10232 KB |
Output is correct |
2 |
Correct |
164 ms |
10232 KB |
Output is correct |
3 |
Correct |
168 ms |
10252 KB |
Output is correct |
4 |
Correct |
164 ms |
10232 KB |
Output is correct |
5 |
Correct |
171 ms |
10232 KB |
Output is correct |
6 |
Correct |
163 ms |
10232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
84 ms |
10564 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Runtime error |
79 ms |
10488 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Runtime error |
79 ms |
10616 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Runtime error |
79 ms |
10488 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
85 ms |
10488 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
81 ms |
10464 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
79 ms |
10528 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
79 ms |
10492 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
67 ms |
8504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
26 ms |
3548 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
41 ms |
5424 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
2 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
2 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
3 ms |
508 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |