#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int dp[205][505][505];
int dp2[2005][10005];
bool subtask4(vector <int> b) {
for (auto x: b)
if (x != b[0])
return 0;
return 1;
}
int find_maximum_unique(int x, int y, vector <int> a, vector <int> b) {
int n = a.size();
if (x <= 500 && y <= 500 && n <= 200) {
// subtask 1, 2
//int dp[n + 10][x + 10][y + 10] = {0};
for (int i = 1; i <= n; i++) {
for (int xx = 0; xx <= x; xx++) {
for (int yy = 0; yy <= y; yy++) {
dp[i][xx][yy] = dp[i - 1][xx][yy];
if (xx >= a[i - 1])
dp[i][xx][yy] = max(dp[i][xx][yy], dp[i - 1][xx - a[i - 1]][yy] + 1);
if (yy >= b[i - 1])
dp[i][xx][yy] = max(dp[i][xx][yy], dp[i - 1][xx][yy - b[i - 1]] + 1);
}
}
}
int ans = dp[n][0][0];
for (int xx = 0; xx <= x; xx++)
for (int yy = 0; yy <= y; yy++)
ans = max(ans, dp[n][xx][yy]);
return ans;
}
else if (subtask4(b)) {
// iau cele mai ieftine din a, dupa care cat pot din b
sort(a.begin(), a.end());
int poz = 0, sum = 0;
while (poz <= n - 1 && sum + a[poz] <= x)
sum += a[poz], poz++;
sum = 0;
while (poz <= n - 1 && sum + b[poz] <= y)
sum += b[poz], poz++;
return poz;
}
else {
// subtaskul 5
sort(a.begin(), a.end());
sort(b.begin(), b.end());
for (int i = 1; i <= n; i++) {
for (int xx = 0; xx <= x; xx++) {
// iau primele i, consum xx in A; cat consum minim in B?
dp2[i][xx] = INF;
if (xx >= a[i - 1])
dp2[i][xx] = min(dp2[i][xx], dp2[i - 1][xx - a[i - 1]]);
dp2[i][xx] = min(dp2[i][xx], dp2[i - 1][xx] + b[i - 1]);
}
}
int ret = 0;
while (ret < n) {
// caut dp2[ret + 1][xx] <= y
bool ok = 0;
for (int xx = 0; xx <= x; xx++)
if (dp2[ret + 1][xx] <= y)
ok = 1;
if (ok)
ret++;
else
break;
}
return ret;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int x, y, n;
cin >> n >> x >> y;
vector <int> a(n), b(n);
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i];
cout << find_maximum_unique(x, y, a, b);
return 0;
}
Compilation message
/tmp/ccM2D7WE.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccYTQcpu.o:jelly.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status