Submission #928624

# Submission time Handle Problem Language Result Execution time Memory
928624 2024-02-16T19:26:00 Z blacktulip Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
461 ms 81920 KB
#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=0;i<30;i++){
		sort(v[i].begin(),v[i].end());
		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++;}
	}
	cout<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 169 ms 27100 KB not a zalsequence
2 Incorrect 172 ms 27076 KB not a zalsequence
3 Incorrect 172 ms 26780 KB not a zalsequence
4 Incorrect 166 ms 26944 KB not a zalsequence
5 Incorrect 170 ms 27468 KB not a zalsequence
6 Incorrect 163 ms 27636 KB not a zalsequence
# Verdict Execution time Memory Grader output
1 Incorrect 161 ms 26468 KB not a zalsequence
2 Incorrect 167 ms 27876 KB not a zalsequence
3 Incorrect 169 ms 26676 KB not a zalsequence
4 Incorrect 175 ms 27188 KB not a zalsequence
5 Incorrect 160 ms 28136 KB not a zalsequence
6 Incorrect 162 ms 29036 KB not a zalsequence
7 Incorrect 165 ms 27328 KB not a zalsequence
8 Incorrect 169 ms 27220 KB not a zalsequence
9 Incorrect 203 ms 39904 KB not a zalsequence
10 Incorrect 339 ms 70972 KB not a zalsequence
11 Incorrect 298 ms 55048 KB not a zalsequence
12 Incorrect 456 ms 81712 KB not a zalsequence
13 Incorrect 443 ms 81836 KB not a zalsequence
14 Incorrect 461 ms 81920 KB not a zalsequence