93292024-02-20 14:26:57ananászÓvodacpp17Wrong answer 28/50120ms14548 KiB
// ovoda.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct szerep {
	int akt_db;
	int max_db;
};
struct gyerek {
	int kivant;
	int siras;
	int kapott;
	int id;
};
bool rendez(gyerek gy1, gyerek gy2) {
	return gy1.siras > gy2.siras;
}
bool rendez2(gyerek gy1, gyerek gy2) {
	return gy1.id< gy2.id;
}
int main()
{
	int N, K;
	cin >> N >> K;
	vector<szerep>szerepek(K);
	int x;
	for (int i = 0; i < K; i++)
	{
		cin >> x;
		szerepek[i].max_db = x;
		szerepek[i].akt_db = 0;
	}
	vector<gyerek>gyerekek(N);
	for (int i = 0; i < N; i++)
	{
		cin >> x;
		gyerekek[i].kivant = x;
		gyerekek[i].kapott = -1;
		gyerekek[i].id = i;
	}
	for (int i = 0; i < N; i++)
	{
		cin >> x;
		gyerekek[i].siras = x;
	}
	sort(gyerekek.begin(), gyerekek.end(), rendez);
	int siras = 0;
	for (int i = 0; i < N; i++)
	{
		if (szerepek[gyerekek[i].kivant-1].akt_db < szerepek[gyerekek[i].kivant-1].max_db)
		{
			szerepek[gyerekek[i].kivant-1].akt_db++;
			gyerekek[i].kapott = gyerekek[i].kivant;
		}
		else
		{
			siras += gyerekek[i].siras;
		}
	}
	cout << siras<<endl;
	int id = 0;
	string sep = "";
	sort(gyerekek.begin(), gyerekek.end(), rendez2);
	for (int i = 0; i < N; i++)
	{
		if (gyerekek[i].kapott==-1)
		{
			while (szerepek[id].max_db == szerepek[id].akt_db)
			{
				id++;
			}
			//gyerekek[i].kapott=id+1;
			szerepek[id].akt_db++;
			cout <<sep<< id + 1;
		}
		else
		{
			cout << sep << gyerekek[i].kapott;
		}
		sep = " ";
	}
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base28/50
1Accepted0/03ms1808 KiB
2Wrong answer0/07ms2152 KiB
3Accepted2/23ms2224 KiB
4Partially correct1/23ms2436 KiB
5Accepted2/23ms2652 KiB
6Accepted2/23ms2868 KiB
7Wrong answer0/23ms3072 KiB
8Partially correct1/23ms3200 KiB
9Accepted2/23ms3392 KiB
10Accepted2/23ms3476 KiB
11Accepted2/23ms3608 KiB
12Partially correct1/23ms3628 KiB
13Wrong answer0/23ms3768 KiB
14Accepted3/34ms4004 KiB
15Wrong answer0/314ms4656 KiB
16Wrong answer0/332ms5628 KiB
17Accepted3/346ms6464 KiB
18Wrong answer0/371ms8388 KiB
19Accepted3/382ms9176 KiB
20Accepted3/392ms10428 KiB
21Partially correct1/3107ms12204 KiB
22Wrong answer0/4120ms14548 KiB