666
2025-01-22 11:16:53
发布于:广东
12阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int a[10001],b[10001],n,s,x,y;
int main() {
cin >> n >> s;
cin >> x >> y;
y += x;
for(int i = 1;i <= n;i++) cin >> a[i] >> b[i];
for(int i = 1;i < n;i++){
for(int j = 1;j <= n - i;j++){
if(b[j] > b[j + 1]){
swap(b[j],b[j + 1]);
swap(a[j],a[j + 1]);
}
}
}
int cnt = 0;
for(int i = 1;i <= n;i++){
if(a[i] <= y && b[i] <= s){
cnt++;
s -= b[i];
}
}
cout << cnt;
}
这里空空如也
有帮助,赞一个