#include <bits/stdc++.h>
#define all(v) ((v).begin(),(v).end())
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll mxN = 4e6 + 5;
int a[mxN];
stack<int>st;
deque<pair<int,int>>dq;
vector<pair<int,int>>v;
signed main() {
// ios_base::sync_with_stdio(0);
// cin.tie(0);cout.tie(0);
int n,k;
cin >>n>>k;
for(int i = 0 ;i < n;i++){
cin >>a[i];
}
st.push(a[0]);
for(int i = 1;i < n;i++){
int u = st.top();
while(u < a[i]){
// cout<<u<<' '<<i - 1<<'\n';
dq.push_back({u,i - 1});
u++;
st.pop();
if(st.size() && st.top() == u){
st.pop();
u++;
}
st.push(u);
}
u = a[i];
while(st.size() && u == st.top()){
u++;
st.pop();
}
st.push(u);
}
while(st.size()){
int u = st.top();
if(u == 30) break;
// cout<<u<<'\n';
st.pop();
u++;
dq.push_front({u,n - 1});
if(st.size() && st.top() == u){
st.pop();
u++;
}
st.push(u);
}
int rm = dq.size();
while(dq.size()){
while(dq.front().first != 0 && rm < k){
pair<int,int> u = dq.front();
dq.pop_front();
dq.push_front({u.first - 1,u.second});
dq.push_front({u.first - 1,u.second});
rm++;
}
v.push_back(dq.front());
dq.pop_front();
}
int idx = 0;
for(int i = 0;i < n;i++){
cout<<a[i]<<' ';
while(v[idx].second == i){
cout<<v[idx].first<<' ';
idx++;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
227 ms |
6252 KB |
Expected EOF |
2 |
Incorrect |
245 ms |
6268 KB |
Expected EOF |
3 |
Incorrect |
243 ms |
6304 KB |
Expected EOF |
4 |
Incorrect |
244 ms |
6204 KB |
Expected EOF |
5 |
Incorrect |
254 ms |
6336 KB |
Expected EOF |
6 |
Incorrect |
232 ms |
6232 KB |
Expected EOF |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
273 ms |
6292 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
236 ms |
6356 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
225 ms |
6488 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
222 ms |
6220 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
242 ms |
6428 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
227 ms |
6352 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
236 ms |
6264 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
216 ms |
6424 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
258 ms |
8504 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
140 ms |
11064 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
151 ms |
9688 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
104 ms |
10232 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
120 ms |
10212 KB |
Unexpected end of file - int32 expected |
14 |
Runtime error |
118 ms |
18724 KB |
Execution killed with signal 11 |