Lanhening @ 2024-11-13 21:32:00
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
struct s{
int x,y;
}a[5005];
bool cmp(const s &a,s &b){
if(a.y!=b.y) return a.y<b.y;
}
int main(){
int sum=0,n,u,w,f;
cin>>n>>f>>u>>w;
for(int i=1;i<=n;i++){
cin>>a[i].x>>a[i].y;
}
sort(a+1,a+1+n,cmp);
int g=0;
while(f>0){
g++;
if(a[g].y<=f&&(u+w)>=a[g].x){
f-=a[g].y;
sum++;
}
}
cout<<sum<<endl;
return 0;
}
by Lanhening @ 2024-11-13 21:32:38
在线等!!!
by niuniudundun @ 2024-11-13 22:02:39
@Lanhening 应该是 f>0
为 f>=0
。
我是这么写的。求关