# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
568594 |
2022-05-25T18:43:11 Z |
urosk |
Zalmoxis (BOI18_zalmoxis) |
C++14 |
|
168 ms |
10928 KB |
// __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];
v.pb(x);
while(sz(v)>1&&v[sz(v)-1]==v[sz(v)-2]){
ll x = v.back()+1;
v.popb();
v.popb();
v.pb(x);
last = i;
e = x;
bio = 1;
}
}
if(bio){
if(sz(v)==1){
for(ll i = 1;i<=n;i++) cout<<a[i]<< " ";
cout<<v[0]<<endl;
return 0;
}
ll mn = llinf;
for(ll x : v) mn = min(mn,x);
v.clear();
for(ll i = 1;i<=n;i++){
ll x = a[i];
v.pb(x);
while(sz(v)>1&&v[sz(v)-1]==v[sz(v)-2]){
ll x = v.back()+1;
v.popb();
v.popb();
v.pb(x);
last = i;
e = x;
}
cout<<a[i]<< " ";
if(v.back()==mn) cout<<mn<< " ";
}
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;
}
Compilation message
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:31:8: warning: variable 'last' set but not used [-Wunused-but-set-variable]
31 | ll last = -1;
| ^~~~
zalmoxis.cpp:32:8: warning: variable 'e' set but not used [-Wunused-but-set-variable]
32 | ll e = -1;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
146 ms |
10208 KB |
Expected EOF |
2 |
Incorrect |
143 ms |
10208 KB |
Expected EOF |
3 |
Incorrect |
160 ms |
10188 KB |
Expected EOF |
4 |
Incorrect |
141 ms |
10196 KB |
Expected EOF |
5 |
Incorrect |
149 ms |
10276 KB |
Expected EOF |
6 |
Incorrect |
155 ms |
10176 KB |
Expected EOF |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
147 ms |
10204 KB |
Expected EOF |
2 |
Incorrect |
168 ms |
10584 KB |
Expected EOF |
3 |
Incorrect |
143 ms |
10704 KB |
Expected EOF |
4 |
Incorrect |
147 ms |
10256 KB |
Expected EOF |
5 |
Incorrect |
163 ms |
10288 KB |
Expected EOF |
6 |
Incorrect |
143 ms |
10336 KB |
Expected EOF |
7 |
Incorrect |
145 ms |
10188 KB |
Expected EOF |
8 |
Incorrect |
157 ms |
10396 KB |
Expected EOF |
9 |
Incorrect |
124 ms |
10928 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
46 ms |
4984 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
76 ms |
8268 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
1 ms |
212 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
1 ms |
212 KB |
Unexpected end of file - int32 expected |