haley001 @ 2024-08-13 14:23:32
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct apple {
int s, h;
} ap[5010];
int n, s, a, b, ans;
bool cmp(apple a, apple b) {
return a.s < b.s;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> s >> a >> b;
a += b;
for (int i = 1; i <= n; i++)cin >> ap[i].h >> ap[i].s;
sort(ap + 1, ap + n + 1, cmp);
for (int i = 1; i <= n; i++) {
if (s < 0)break;
if (a >= ap[i].h)s -= ap[i].s, ans++;
}
cout << max(0ll, ans - 1);
return 0;
}
by lingquan @ 2024-09-14 17:35:57
是对的啊?怎么了