ouruiheng0929 @ 2023-10-20 22:08:23
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,s,a,b,li[5010],qi[5010];
bool cmp(int x,int y){
if(x>y) return x>y;
}
int main(){
// freopen("taotao.in","r",stdin);
// freopen("taotao.out","w",stdout);
cin>>n>>s>>a>>b;
for(int i=1;i<=n;i++) cin>>li[i]>>qi[i];
int t=a+b,c=1,sum=0,bb=1;
for(int i=1;i<=n;i++){
if(t>=li[i]) li[c]=li[i],qi[c]=qi[i];
c++;
}
sort(qi,qi+n+1,cmp);
while(sum<=s){
sum+=qi[bb];
bb++;
}
cout<<bb-1;
return 0;
}