思路:加特判的一维01背包
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int w[5001];
int dp[5001];
int c[5001];
int n,s,a,b,mn;
int main ()
{
cin>>n>>s;
cin>>a>>b;
for (int i=1;i<=n;i++)
{
cin>>c[i]>>w[i];
}
for (int l=1;l<=n;l++)
for (int i=s;i>=w[l];i--)
{
if (c[l]<=a+b)//注意判断能否摘得到来转移
dp[i]=max(dp[i],dp[i-w[l]]+1);
mn=max(mn,dp[i]);
}
cout<<mn;
return 0;
}