# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
750154 | MrM7md | Zalmoxis (BOI18_zalmoxis) | C++17 | 221 ms | 77932 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
const int N=1e6+500;
const int off=(1<<18);
const int MOD = 1e9+7;
vector<vector<int>>kk(N),ans(N);
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,k;
cin >> n >> k;
vector<pair<int,int>> a(n);
for(int i=0;i<n;i++){
cin >> a[i].F;
a[i].S=i;
}
vector<pair<int,int>>v=a;
for(int i=0;i<=29;i++){
vector<pair<int,int>>t;
for(int j=0;j<v.size();j++){
if(j+1<v.size()&&v[j].F==v[j+1].F&&v[j].F==i){
t.pb({v[j].F+1,v[j+1].S});
j++;
}
else if(v[j].F==i){
t.pb({v[j].F+1,v[j].S});
kk[v[j].S].pb(v[j].F);
k--;
}
else{
t.pb(v[j]);
}
}
v=t;
}
for(int i=0;i<n;i++){
for(auto it:kk[i]){
ans[i].pb(it);
while(k>0&&ans[i].back()>0){
int x=ans[i].back()-1;
ans[i].pop_back();
ans[i].pb(x),ans[i].pb(x);
k--;
}
}
}
for(int i=0;i<n;i++){
cout<<a[i].F<<' ';
for(auto it:ans[i])cout<<it<<' ';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |