//TrungNotChung
#include <iostream>
#include <bits/stdc++.h>
#include <queue>
#include <set>
#define foru(i,a,b) for(int i=a ; i<=b ; ++i)
#define ford(i,a,b) for(int i=b ; i>=a ; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define oo (int)1e9
#define __builtin_popcount __builtin_popcountll
using namespace std;
const int N = 2000;
const int M = 10000;
struct Jelly
{
int a , b;
bool operator < (const Jelly &x)
{
return a < x.a;
}
}f[N];
int dp[N+1][M+1];
int suf[N+1][N+1] , num[N+1][M+1];
int n , w1 , w2;
void solve()
{
cin >> n >> w1 >> w2;
for(int i=1 ; i<=n ; ++i)
{
cin >> f[i].a >> f[i].b;
}
sort(f+1 , f+n+1);
for(int i=1 ; i<=n ; ++i) for(int j=1 ; j<=n ; ++j) suf[i][j] = oo;
for(int i=n ; i>=1 ; --i)
{
for(int j=1 ; j<=(n-i+1) ; ++j)
{
if(i==n)
{
suf[i][j] = f[i].b;
}
else
{
suf[i][j] = min(suf[i+1][j] , suf[i+1][j-1]+f[i].b);
}
if(suf[i][j] <= M) num[i][suf[i][j]] = max(num[i][suf[i][j]] , j);
}
for(int j=1 ; j<=M ; ++j) num[i][j] = max(num[i][j-1] , num[i][j]);
}
int ans = 0;
for(int i=1 ; i<=n ; ++i)
{
for(int j=0 ; j<=w1 ; ++j)
{
dp[i][j] = dp[i-1][j]+f[i].b;
if(j>=f[i].a) dp[i][j] = min(dp[i-1][j-f[i].a] , dp[i][j]);
if(dp[i][j] <= w2)
{
ans = max(ans , i+num[i+1][w2-dp[i][j]]);
}
}
}
cout << ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//freopen("JELLY.INP" , "r" , stdin);
//freopen("JELLY.OUT" , "w" , stdout);
solve();
return 0;
}
Compilation message
/tmp/ccJXiu29.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccMDwiCX.o:jelly.cpp:(.text.startup+0x0): first defined here
/tmp/ccJXiu29.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