#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>;
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,k;
cin>>n>>k;
deque<int>a,b(n);
for(auto &i:b)cin>>i;
deque<int>dq={b[0]};
a.push_back(b[0]);
b.pop_front();
while(b.size()){
if(b[0]<=a.back()){
a.push_back(b[0]);
dq.push_back(b[0]);
b.pop_front();
}else{
k--;
a.push_back(a.back());
dq.push_back(a.back());
}
while(a.size()>1&&a.back()==a[a.size()-2]){
int A=a.back();
a.pop_back();
a.pop_back();
a.push_back(A+1);
}
}
while(a.size()>1){
a.push_back(a.back());
dq.push_back(a.back());
k--;
while(a.size()>1&&a.back()==a[a.size()-2]){
int A=a.back();
a.pop_back();
a.pop_back();
a.push_back(A+1);
}
}
int g=a.back();
// while(k--){
// dq.push_back(g++);
// }
for(auto &i:dq)cout<<i<<' ';
}
Compilation message
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:46:9: warning: unused variable 'g' [-Wunused-variable]
46 | int g=a.back();
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
122 ms |
10812 KB |
Output is correct |
2 |
Correct |
140 ms |
10800 KB |
Output is correct |
3 |
Correct |
122 ms |
10792 KB |
Output is correct |
4 |
Correct |
123 ms |
10820 KB |
Output is correct |
5 |
Correct |
128 ms |
10740 KB |
Output is correct |
6 |
Correct |
129 ms |
10784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
127 ms |
10788 KB |
Unexpected end of file - int32 expected |
2 |
Correct |
123 ms |
10800 KB |
Output is correct |
3 |
Incorrect |
141 ms |
10912 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
134 ms |
10784 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
125 ms |
10784 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
129 ms |
10792 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
124 ms |
10780 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
126 ms |
10804 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
115 ms |
10076 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
50 ms |
4796 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
75 ms |
7056 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
1 ms |
212 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
1 ms |
212 KB |
Unexpected end of file - int32 expected |