题解
2024-02-22 14:59:11
发布于:云南
44阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int n,k,r,b,s;
int ans = 0;
struct node{
int x,y;
}a[5005];
bool cmp(node xx,node yy){
return xx.y < yy.y;
}
int main(){
cin >> n >> k;
cin >> r >> b;
s = r + b;
for(int i = 1;i <= n;i++) cin >> a[i].x >> a[i].y;
sort(a + 1,a + n + 1,cmp);
for(int i = 1;i <= n;i++){
if(a[i].x <= s && k - a[i].y >= 0){
ans++;
k -= a[i].y;
}
}
cout << ans;
return 0;
}
这里空空如也
有帮助,赞一个