Echordy @ 2022-11-27 23:39:54
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,s,a,b;
cin>>n>>s;
cin>>a>>b;
int x,y;
int ap[10005]={0};
int j=0;
for(int i=1;i<=n;i++){
cin>>x>>y;
if(x<=b+a){
ap[j]=y;
j++;
}
else continue;
}
sort(&ap[0],&ap[j]);
int count=0;
int sum=ap[0];
for(int i=0;i<j;i++){
if(sum+ap[i]<=s){
sum+=ap[i];
count++;
}
else break;
}
cout<<count<<endl;
}