#include using namespace std; typedef long long LL; const int N = 5010; int n, s; //苹果数 n,力气 s int a, B; //椅子的高度a,陶陶手伸直的最大长度b。 struct apple { int x, y; } apples[N]; bool cmp(const apple &a, const apple &b) { return a.y < b.y; } int cnt; //结果数 //每行两个数 苹果高度 xi,摘这个苹果需要的力气yi int main() { cin >> n >> s >> a >> b; for (int i = 1; i <= n; i++) cin >> apples[i].x >> apples[i].y; //排序 sort(apples + 1, apples + 1 + n, cmp); for (int i = 1; i <= n; i++) if (a + b >= apples[i].x && s >= apples[i].y) {//能够的到,而且力气够用 cnt++; s -= apples[i].y; } //输出大吉 cout << cnt << endl; return 0; }