98672024-03-13 16:11:49GervidBányász RPG (40 pont)cpp17Time limit exceeded 24/40400ms7408 KiB
#include <iostream>
#include <set>

using namespace std;

int main()
{
	unsigned int n, i, xp = 0, minutes = 0, max, maxi, min = 2147483647, mini;
	cin >> n;

	unsigned int* xpthreshold = new unsigned int[n];
	unsigned int* remaining = new unsigned int[n];

	for (i = 0; i < n; i++)
	{
		cin >> xpthreshold[i];
	}

	for (i = 0; i < n; i++)
	{
		cin >> remaining[i];
	}

	set<unsigned int> done;
	int lastsize = -1;
	
	while (done.size() < n)
	{
		if (done.size() != lastsize)
		{
			lastsize = done.size();
			
			min = 2147483647;
			for (i = 0; i < n; i++)
			{
				if (done.count(i) == 0 && xpthreshold[i] < min)
				{
					min = xpthreshold[i];
					mini = i;
					if (min <= xp)
					{
						break;
					}
				}
			}
		}

		if (xp >= min)
		{
			done.insert(mini);
			minutes += remaining[mini];
			xp += remaining[mini];
			continue;
		}

		lastsize = -1;
		while (xp < min && done.size() < n)
		{
			if (done.size() != lastsize)
			{
				lastsize = done.size();

				max = 0;
				for (i = 0; i < n; i++)
				{
					if (done.count(i) == 0 && xpthreshold[i] > max)
					{
						max = xpthreshold[i];
						maxi = i;
					}
				}
			}
			if (remaining[maxi]-- <= 1)
			{
				done.insert(maxi);
			}
			minutes += 2;
			xp++;
		}
	}
	cout << minutes;
}
SubtaskSumTestVerdictTimeMemory
base24/40
1Accepted0/03ms1812 KiB
2Time limit exceeded0/0398ms1676 KiB
3Accepted2/23ms2432 KiB
4Accepted2/224ms2824 KiB
5Time limit exceeded0/2351ms2332 KiB
6Time limit exceeded0/2374ms2948 KiB
7Time limit exceeded0/2374ms3664 KiB
8Time limit exceeded0/2344ms3204 KiB
9Accepted3/33ms4116 KiB
10Accepted3/33ms4032 KiB
11Accepted3/33ms3924 KiB
12Accepted3/37ms4340 KiB
13Accepted4/418ms4212 KiB
14Accepted4/46ms4404 KiB
15Time limit exceeded0/2400ms4608 KiB
16Time limit exceeded0/2375ms5660 KiB
17Time limit exceeded0/2365ms6328 KiB
18Time limit exceeded0/2354ms7408 KiB