#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=1000010, inf=2e9;
int n, k;
int A[MX];
void comp(vector<int> &V){
int sz=V.size();
while(sz>1 && V[sz-2]==V[sz-1]){
V.pop_back(), V[sz-2]++, sz--;
}
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n>>k;
assert(k==1);
for(int i=1; i<=n; i++) cin>>A[i];
vector<int> V;
list<int> B;
for(int i=1; i<=n; i++) B.push_back(A[i]);
for(auto it=B.begin(); it!=B.end();){
if(V.empty()) { V.push_back(*it); it++; continue; }
if(V.back()<*it) { B.insert(it, V.back()); it--; continue; }
V.push_back(*it);
comp(V);
it++;
}
if(V.back()!=30) B.push_back(V.back()), V.push_back(V.back());
comp(V);
assert(V[0]==30);
for(int x:B) cout<<x<<' ';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
249 ms |
37624 KB |
Output is correct |
2 |
Correct |
290 ms |
37744 KB |
Output is correct |
3 |
Correct |
279 ms |
37776 KB |
Output is correct |
4 |
Correct |
398 ms |
37844 KB |
Output is correct |
5 |
Correct |
251 ms |
37844 KB |
Output is correct |
6 |
Correct |
402 ms |
37892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Runtime error |
4 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Runtime error |
3 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Runtime error |
4 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
3 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
6 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
5 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
4 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
4 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
3 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
4 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
3 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
4 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
4 ms |
37892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |