#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define endl '\n'
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
const int mod = 1e9 + 7;
const int N = 1e6 + 15;
const ll inf = 1e18;
int n,k;
vector<pii> ans;
int cnt = 0;
void pr(int o){
if (k>0&&o>0){
k--;
pr(o-1);
pr(o-1);
return ;
}
cout << o << ' ';
}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin >> n >> k;
stack<int> st;
st.push(100);
vector<int> a(n);
map<int,vector<int>> mp;
for (int i=0;i<n;i++){
int x;
cin >> x;
a[i] = x;
if (x < st.top()){
st.push(x);
continue;
}
if (x > st.top()){
while (x > st.top()){
int u = st.top();
mp[i-1].pb(u);
while (u==st.top()){
st.pop();
u++;
}
st.push(u);
}
}
if (x==st.top()){
int u = st.top();
while (u==st.top()){
st.pop();
u++;
}
st.push(u);
}
}
int x = 30;
while (x > st.top()){
int u = st.top();
mp[n-1].pb(u);
while (u==st.top()){
st.pop();
u++;
}
st.push(u);
}
for (int i=0;i<n;i++){
ans.push_back({a[i],0});
for (auto it : mp[i]) {
ans.push_back({it,1});
k--;
}
}
n = sz(ans);
for (int i=0;i<n;i++){
if (ans[i].S==0){
cout << ans[i].F << ' ';
}
else pr(ans[i].F);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
372 ms |
104088 KB |
Output is correct |
2 |
Correct |
366 ms |
104108 KB |
Output is correct |
3 |
Correct |
425 ms |
104156 KB |
Output is correct |
4 |
Correct |
365 ms |
104092 KB |
Output is correct |
5 |
Correct |
358 ms |
104148 KB |
Output is correct |
6 |
Correct |
367 ms |
104272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
387 ms |
104088 KB |
not a zalsequence |
2 |
Incorrect |
341 ms |
104096 KB |
Expected EOF |
3 |
Incorrect |
311 ms |
104076 KB |
Expected EOF |
4 |
Incorrect |
382 ms |
104128 KB |
not a zalsequence |
5 |
Incorrect |
385 ms |
104172 KB |
not a zalsequence |
6 |
Incorrect |
361 ms |
104192 KB |
not a zalsequence |
7 |
Incorrect |
363 ms |
104080 KB |
not a zalsequence |
8 |
Incorrect |
359 ms |
104144 KB |
not a zalsequence |
9 |
Incorrect |
272 ms |
89508 KB |
not a zalsequence |
10 |
Incorrect |
166 ms |
37604 KB |
not a zalsequence |
11 |
Incorrect |
216 ms |
59172 KB |
not a zalsequence |
12 |
Correct |
68 ms |
2252 KB |
Output is correct |
13 |
Correct |
70 ms |
2236 KB |
Output is correct |
14 |
Correct |
75 ms |
2256 KB |
Output is correct |