andylynette @ 2019-11-10 11:18:33
#include <stdio.h>
int main(){
int n,s,a,b,i,l,p=0,q=1;
int x[281],y[101],z[101]={0};
scanf("%d %d",&n,&s);
scanf("%d %d",&a,&b);
a=a+b;
for(i=0;i<n;i++){
scanf("%d %d",&x[i],&y[i]);
if(x[i]<=a){
z[y[i]]+=1;}
}
for(i=0;i<101;i++){
if(q==0){
break;
}
for(l=z[i];l>0;l--){
s=s-i;
if(s<0){
q=0;break;
}
p++;
}
}
printf("%d",p);
return 0;
}