Doshe @ 2024-07-23 19:01:58
#include <iostream>
#include<algorithm>
using namespace std;
typedef struct zsg{
int h;
int lq;
}zsg;
bool cmp2(zsg a,zsg b){
return a.lq<b.lq;
}
int main(){
int n,s,a,b;
cin>>n>>s;
cin>>a>>b;
zsg zb[5005];
for(int i=0;i<n;i++){
scanf("%d %d",&zb[i].h,&zb[i].lq);
}
sort(zb,zb+n,cmp2);
int sum=0;
int i=0;
int sum2=0;
while(sum<=s&&i<n){
if(zb[i].h<=(a+b)){
sum2++;
sum+=zb[i].lq;
}
i++;
}
if(sum<s) cout<<sum2;
if(sum>=s) cout<<sum2-1;
}
by Doshe @ 2024-07-23 19:34:38
@Finner_forgeter 对对对,一看就是acmer。(老师提醒好几遍了,还是没养成好习惯)