41382023-03-15 13:41:20horvathabelÓvodacpp17Wrong answer 19/50105ms16708 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
int n,m;
cin>>n>>m;
vector<int> db; 
for (int i=0; i<m;i++){
	int z;
	cin>>z;
	db.push_back(z);
}
vector<int> ak,sir;
for (int i=0; i<n;i++){
	int x;
	cin>>x;
	x--;
	ak.push_back(x);
}
for (int i=0; i<n;i++){
	int x;
	cin>>x;
	sir.push_back(x);
}
vector<priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>>> q(m);
for (int i=0; i<n;i++){
	q[ak[i]].push({sir[i],i});
}
int ans=0;
queue<int> plussz;
for (int i=0; i<m;i++){
	while (q[i].size()>db[i]){
		plussz.push(q[i].top().second);
		ans+=q[i].top().first;
		q[i].pop();
	}

	
}

cout<<ans<<endl; 
for (int i=0; i<m;i++){
	while (q[i].size()<=db[i] && !plussz.empty()){
		ak[plussz.front()]=i;
		q[i].push({plussz.front(),0});
		plussz.pop();
		
	}
}
for (auto i:ak) cout<<i+1<<" "; 
}
SubtaskSumTestVerdictTimeMemory
base19/50
1Wrong answer0/03ms1812 KiB
2Wrong answer0/07ms2428 KiB
3Partially correct1/23ms2220 KiB
4Partially correct1/23ms2440 KiB
5Partially correct1/23ms2780 KiB
6Accepted2/23ms2932 KiB
7Wrong answer0/23ms3008 KiB
8Partially correct1/23ms3164 KiB
9Accepted2/23ms3228 KiB
10Partially correct1/23ms3340 KiB
11Accepted2/23ms3344 KiB
12Partially correct1/23ms3556 KiB
13Wrong answer0/23ms3604 KiB
14Partially correct1/33ms3480 KiB
15Wrong answer0/313ms4332 KiB
16Wrong answer0/328ms6592 KiB
17Accepted3/335ms5600 KiB
18Wrong answer0/359ms10004 KiB
19Partially correct1/364ms7608 KiB
20Partially correct1/371ms8704 KiB
21Partially correct1/385ms9672 KiB
22Wrong answer0/4105ms16708 KiB