#include <bits/stdc++.h>
using namespace std;
#define ort ((bas+son)/2)
#define int long long
#define endl "\n"
#define pb push_back
#define fi first
#define se second
int n,k,a[1000005];
vector<int> v[35];
int32_t main(void){
//~ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>k;
multiset<pair<int,int>> ekle;
for(int i=1;i<=n;i++){
cin>>a[i];
v[a[i]].pb(i);
//~ ekle.insert({a[i],i});
}
cout<<"**\n";
for(int i=1;i<30;i++){
int siz=v[i].size();
if(siz%2==0){
for(int j=siz/2;j<siz;j++)v[i+1].pb(v[i][j]);
v[i].clear();
}
else{
//~ cout<<i<<" ()())(()() \n";
ekle.insert({i,v[i][0]});
for(int j=siz/2;j<siz;j++)v[i+1].pb(v[i][j]);
v[i].clear();
}
}
//~ cout<<"**\n";
while((int)ekle.size()<k){
auto it=ekle.end();
it--;
int val=it->fi;
int ind=it->se;
ekle.erase(it);
val--;
ekle.insert({val,ind});
ekle.insert({val,ind});
}
vector<pair<int,int>> ans;
while(ekle.size()){
auto it=ekle.begin();
ans.pb({it->se,it->fi});
//~ cout<<it->se<<" ()() "<<it->fi<<endl;
ekle.erase(it);
}
sort(ans.begin(),ans.end());
int sayac=0;
int sizz=ans.size();
for(int i=1;i<=n;i++){
cout<<a[i]<<" ";
while(sayac<sizz && ans[sayac].fi==i){cout<<ans[sayac].se<<" ";sayac++;}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
185 ms |
27416 KB |
Expected integer, but "**" found |
2 |
Incorrect |
194 ms |
28008 KB |
Expected integer, but "**" found |
3 |
Incorrect |
176 ms |
27548 KB |
Expected integer, but "**" found |
4 |
Incorrect |
173 ms |
27856 KB |
Expected integer, but "**" found |
5 |
Incorrect |
173 ms |
28016 KB |
Expected integer, but "**" found |
6 |
Incorrect |
177 ms |
27992 KB |
Expected integer, but "**" found |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
174 ms |
27596 KB |
Expected integer, but "**" found |
2 |
Incorrect |
175 ms |
28528 KB |
Expected integer, but "**" found |
3 |
Incorrect |
175 ms |
27532 KB |
Expected integer, but "**" found |
4 |
Incorrect |
175 ms |
28116 KB |
Expected integer, but "**" found |
5 |
Incorrect |
175 ms |
28504 KB |
Expected integer, but "**" found |
6 |
Incorrect |
171 ms |
29736 KB |
Expected integer, but "**" found |
7 |
Incorrect |
185 ms |
28328 KB |
Expected integer, but "**" found |
8 |
Incorrect |
178 ms |
28616 KB |
Expected integer, but "**" found |
9 |
Incorrect |
222 ms |
40400 KB |
Expected integer, but "**" found |
10 |
Incorrect |
368 ms |
71860 KB |
Expected integer, but "**" found |
11 |
Incorrect |
295 ms |
54984 KB |
Expected integer, but "**" found |
12 |
Incorrect |
461 ms |
81840 KB |
Expected integer, but "**" found |
13 |
Incorrect |
442 ms |
82116 KB |
Expected integer, but "**" found |
14 |
Incorrect |
464 ms |
81664 KB |
Expected integer, but "**" found |