```cpp
#include <bits/stdc++.h>
using namespace std;
struct tree{
int x,y;
};
bool cmp(tree a,tree b){
return a.y<b.y;
}
int main() {
tree tre[100001];
int n,s,a,b,cnt=0;
cin>>n>>s>>b>>a;
for(int i=1;i<=n;i++){
cin>>tre[i].x>>tre[i].y;
}
sort(tre+1,tre+n+1,cmp);
for(int i=1;i<=n;i++){
if(tre[i].x<=a+b&&tre[i].y<=s){
s-=tre[i].y;
cnt++;
}
}
cout<<cnt;
return 0;
}
```
by wsh88 @ 2023-05-03 20:45:29
OK
已改
记得关住一下我!!!
by wsh88 @ 2023-05-03 20:47:48