답안 #928617

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
928617 2024-02-16T19:16:55 Z blacktulip Zalmoxis (BOI18_zalmoxis) C++17
5 / 100
458 ms 82408 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=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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 96 ms 25468 KB Expected EOF
2 Incorrect 96 ms 26048 KB Expected EOF
3 Incorrect 93 ms 25564 KB Expected EOF
4 Incorrect 99 ms 25816 KB Expected EOF
5 Incorrect 97 ms 26028 KB Expected EOF
6 Incorrect 93 ms 25952 KB Expected EOF
# 결과 실행 시간 메모리 Grader output
1 Incorrect 94 ms 25396 KB not a zalsequence
2 Incorrect 99 ms 26816 KB not a zalsequence
3 Incorrect 94 ms 25408 KB not a zalsequence
4 Incorrect 98 ms 26308 KB not a zalsequence
5 Incorrect 94 ms 26916 KB not a zalsequence
6 Incorrect 95 ms 27740 KB not a zalsequence
7 Incorrect 97 ms 26132 KB not a zalsequence
8 Incorrect 94 ms 26108 KB not a zalsequence
9 Incorrect 149 ms 38888 KB not a zalsequence
10 Incorrect 326 ms 70980 KB not a zalsequence
11 Incorrect 259 ms 53996 KB not a zalsequence
12 Incorrect 458 ms 82368 KB not a zalsequence
13 Incorrect 436 ms 82040 KB not a zalsequence
14 Correct 453 ms 82408 KB Output is correct