87352024-01-26 21:08:52bovizdbBányász RPG (40 pont)cpp17Time limit exceeded 30/40400ms6884 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> l(n), m(n);
	int a = 0;
	for (int i = 0; i < n; i++) cin >> l[i];
	for (int i = 0; i < n; i++) cin >> m[i];
	for (int i = 0; i < n; i++) a += m[i];
	int t = 0, k = 0;
	while(a > 0)
	{
		bool b = 0;
		for (int i = 0; i < n; i++)
		{
			if (k >= l[i])
			{
				t += m[i];
				a -= m[i];
				k += m[i];
				m[i] = 0;
				b = 1;
				continue;
			}
		}
		if (b == 0)
		{
			int mx = 0, mxi;
			for (int i = 0; i < n; i++)
			{
				if (mx < m[i])
				{
					mx = m[i];
					mxi = i;
				}
			}
			t += 2;
			a--;
			k++;
			m[mxi]--;
		}
	}
	cout << t;
}
	
SubtaskSumTestVerdictTimeMemory
base30/40
1Accepted0/03ms1812 KiB
2Accepted0/013ms2556 KiB
3Accepted2/23ms2544 KiB
4Accepted2/23ms2672 KiB
5Time limit exceeded0/2326ms3172 KiB
6Accepted2/227ms3840 KiB
7Accepted2/29ms3296 KiB
8Accepted2/246ms3352 KiB
9Accepted3/33ms3504 KiB
10Accepted3/32ms3628 KiB
11Accepted3/33ms3876 KiB
12Accepted3/33ms3816 KiB
13Accepted4/43ms3824 KiB
14Accepted4/43ms3856 KiB
15Wrong answer0/234ms5160 KiB
16Time limit exceeded0/2400ms4980 KiB
17Wrong answer0/239ms6752 KiB
18Time limit exceeded0/2382ms6884 KiB