제출 #1169188

#제출 시각아이디문제언어결과실행 시간메모리
1169188miniobJelly Flavours (IOI20_jelly)C++20
100 / 100
107 ms157000 KiB
#include <bits/stdc++.h>
using namespace std;

int minimalnykoszt2[2007][10007];
int najlepszysuf2[2007][10007];

int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) 
{
	int n = a.size(), odp = 0;
	vector<pair<int, int>> nowe;
	for(int i = 0; i < n; i++)
	{
		nowe.push_back({a[i], b[i]});
	}
	sort(nowe.begin(), nowe.end());
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j <= x; j++)
		{
			if(nowe[i - 1].first <= j)
			{
				minimalnykoszt2[i][j] = min(minimalnykoszt2[i - 1][j] + nowe[i - 1].second, minimalnykoszt2[i - 1][j - nowe[i - 1].first]);
			}
			else
			{
				minimalnykoszt2[i][j] = minimalnykoszt2[i - 1][j] + nowe[i - 1].second;
			}
		}
		
	}
	for(int i = n; i > 0; i--)
	{
		for(int j = 0; j <= y; j++)
		{
			if(nowe[i - 1].second <= j)
			{
				najlepszysuf2[i][j] = max(najlepszysuf2[i + 1][j], najlepszysuf2[i + 1][j - nowe[i - 1].second] + 1);
			}
			else
			{
				najlepszysuf2[i][j] = najlepszysuf2[i + 1][j];
			}
		}
	}
	for(int i = 0; i <= n; i++)
	{
		if(minimalnykoszt2[i][x] <= y)
		{
			odp = max(odp, i + najlepszysuf2[i + 1][y - minimalnykoszt2[i][x]]);
		}
	}
	return odp;
}

/*int main()
{
	int n, x, y;
	cin >> n >> x >> y;
	vector<int> a(n), b(n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for(int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	cout << find_maximum_unique(x, y, a, b) << endl;
	return 0;
}*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...