#include <bits/stdc++.h>
#define fi first
#define se second
#define PB push_back
#define ll long long
#define int long long
#define ii pair<int, int>
#define vi vector<ll>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vii vector<ii>
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; --i)
#define FORV(v, H) for(auto &v: H)
#define reset(c, x) memset(c, x, sizeof(c))
#define BIT(mask, i) ((mask >> i) & 1)
#define ONBIT(mask, i) (mask | (1LL << (i)))
#define OFFBIT(mask, i) (mask &~ (1LL << (i)))
#define REV(mask, i) (mask ^ (1LL << (i))
#define CBIT __builtin_popcountll
#define lwb lower_bound
#define upb upper_bound
#define all(v) (v.begin(), v.end())
#define task "JELLY"
using namespace std;
const long long oo = 1e18 + 7;
const int MAXN = 1e5 + 7;
const int MOD = 1e9 + 7;
const int MAXV = 1e6 + 7;
int N, X, Y;
int A[MAXN], B[MAXN];
namespace subtask1 {
vvvi dp;
int solve(int id, int coinx, int coiny) {
if(coinx == 0 && coiny == 0) return 0;
if(id > N) return 0;
if(dp[id][coinx][coiny] != -1) return dp[id][coinx][coiny];
int cur = 0;
if(coinx >= A[id]) cur = max(cur, solve(id + 1, coinx - A[id], coiny) + 1);
if(coiny >= B[id]) cur = max(cur, solve(id + 1, coinx, coiny - B[id]) + 1);
return dp[id][coinx][coiny] = cur;
}
void SOLVE() {
dp.assign(N + 5, vvi(X + 2, vi(Y + 2, -1)));
cout << solve(1, X, Y) << '\n';
}
}
namespace subtask3 {
vvi DPA, DPB;
ii C[MAXN];
void SOLVE() {
DPA.assign(N + 5, vi(X + 5, oo));
DPB.assign(N + 5, vi(Y + 5, -oo));
FOR(i, 1, N) C[i] = {A[i], B[i]};
sort(C + 1, C + N + 1);
DPA[0][0] = 0;
FOR(i, 1, N) {
FOR(j, 0, X) {
int d = j - C[i].fi;
if(d >= 0) DPA[i][j] = min(DPA[i][j], DPA[i - 1][d]);
if(DPA[i - 1][j] != oo) {
int costb = DPA[i - 1][j] + C[i].se;
if(costb <= Y) {
DPA[i][j] = min(DPA[i][j], costb);
}
}
}
}
DPB[N] = vi(Y + 5, 0);
FORD(i, N, 1) {
FOR(j, 0, Y) {
int d = j - C[i].se;
DPB[i][j] = max(DPB[i][j], DPB[i + 1][j]);
if(d >= 0) {
DPB[i][j] = max(DPB[i][j], DPB[i + 1][d] + 1);
}
}
}
int ANS = 0;
FOR(i, 0, N) {
FOR(j, 0, X) {
int costb = DPA[i][j];
if(costb <= Y) {
ANS = max(ANS, i + DPB[i + 1][Y - costb]);
}
}
}
cout << ANS << '\n';
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N >> X >> Y;
FOR(i, 1, N) {
cin >> A[i] >> B[i];
}
// if(N * X * Y <= (int) 1e7) {
// subtask1:: SOLVE();
// }
subtask3:: SOLVE();
return 0;
}
Compilation message
/usr/bin/ld: /tmp/ccPXZ8OP.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccKfaS5O.o:jelly.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccPXZ8OP.o: in function `main':
grader.cpp:(.text.startup+0x227): undefined reference to `find_maximum_unique(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status