243602026-02-10 10:34:23SzeredaiNatanaelÓvodacpp17Wrong answer 27/50107ms2852 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int k, n; cin >> k >> n;
	vector<int> maxi(n + 1, 0);
	for (int i = 1; i <= n; ++i) {
		cin >> maxi[i];
	}
	vector<int> szerep(k + 1);
	vector<int> ans(k + 1, 0);
	for (int i = 1; i <= k; ++i) {
		cin >> szerep[i];
	}
	vector<pair<int, int>> siras(k + 1);
	for (int i = 1; i <= k; ++i) {
		cin >> siras[i].first;
		siras[i].second = i;
	}

	int t = 0;
	sort(siras.begin(), siras.end());
	for (int i = k; i >= 1; --i) {
		int j = szerep[siras[i].second];
		if (maxi[j] > 0) {
			--maxi[j];
			ans[siras[i].second] = j;
		}
		else t += siras[i].first;
	}

	int i = 1;
	for (auto& e : ans) {
		if (e == 0) {
			for (int j = i; j <= n; ++j){
				if (maxi[j] > 0) {
					--maxi[j];
					e = j;

					if (maxi[j] == 0) {
						i = j + 1;
					}
					break;
				}
			}
		}
	}

	cout << t << "\n";
	for (int i = 1; i <= k; ++i) {
		cout << ans[i] << " ";
	}
}
SubtaskSumTestVerdictTimeMemory
base27/50
1Accepted0/01ms316 KiB
2Wrong answer0/04ms512 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Partially correct1/21ms316 KiB
6Accepted2/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Partially correct1/21ms316 KiB
9Accepted2/21ms316 KiB
10Accepted2/21ms316 KiB
11Partially correct1/21ms316 KiB
12Partially correct1/21ms316 KiB
13Wrong answer0/22ms316 KiB
14Accepted3/32ms316 KiB
15Wrong answer0/312ms620 KiB
16Wrong answer0/327ms940 KiB
17Accepted3/339ms1300 KiB
18Wrong answer0/361ms1844 KiB
19Accepted3/371ms2100 KiB
20Accepted3/378ms2200 KiB
21Partially correct1/392ms2356 KiB
22Wrong answer0/4107ms2852 KiB