#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
169 ms |
8184 KB |
Output is correct |
2 |
Correct |
162 ms |
8184 KB |
Output is correct |
3 |
Correct |
167 ms |
8188 KB |
Output is correct |
4 |
Correct |
162 ms |
8184 KB |
Output is correct |
5 |
Correct |
162 ms |
8184 KB |
Output is correct |
6 |
Correct |
162 ms |
8184 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
78 ms |
8568 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Runtime error |
78 ms |
8432 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Runtime error |
83 ms |
8440 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Runtime error |
79 ms |
8440 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
81 ms |
8440 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
80 ms |
8568 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
81 ms |
8440 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
78 ms |
8440 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
65 ms |
6876 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
26 ms |
2808 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
43 ms |
4600 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
3 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |