// __builtin_popcount(x)
// __builtin_popcountll(x)
#define here cerr<<"===========================================\n"
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
using namespace std;
#define maxn 1000005
ll n,k;
vector<ll> v;
ll a[maxn];
int main(){
ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
cin >> n >> k;
bool bio = 0;
ll last = -1;
ll e = -1;
for(ll i = 1;i<=n;i++){
cin >> a[i];
ll x = a[i];
if(v.empty()||(sz(v)&&v.back()!=x)) v.pb(x);
else{
while(sz(v)&&x==v.back()){
v.popb();
v.pb(x+1);
last = i;
e = x+1;
bio = 1;
}
}
}
if(bio){
for(ll i = 1;i<=n;i++){
cout<<a[i]<< " ";
if(last==i){
cout<<e<< " ";
}
}
cout<<endl;
}else{
ll mn = llinf;
for(ll i = 1;i<=n;i++) mn = min(mn,a[i]);
for(ll i = 1;i<=n;i++){
cout<<a[i]<< " ";
if(a[i]==mn&&k>0){
cout<<mn<< " ";
k--;
}
}
cout<<endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
164 ms |
18404 KB |
not a zalsequence |
2 |
Incorrect |
162 ms |
18368 KB |
not a zalsequence |
3 |
Correct |
175 ms |
18384 KB |
Output is correct |
4 |
Incorrect |
159 ms |
18344 KB |
not a zalsequence |
5 |
Incorrect |
159 ms |
18324 KB |
not a zalsequence |
6 |
Incorrect |
133 ms |
18296 KB |
not a zalsequence |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
141 ms |
18320 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
133 ms |
18392 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
184 ms |
18260 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
127 ms |
18376 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
130 ms |
18332 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
129 ms |
18392 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
130 ms |
18292 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
141 ms |
18360 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
98 ms |
13868 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
45 ms |
5768 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
62 ms |
9052 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 |
0 ms |
212 KB |
Unexpected end of file - int32 expected |