seer666 @ 2019-10-29 14:59:26
#include<cstdio>
#include<algorithm>
using namespace std;
int c[5001];
int main()
{
int n,s,a,b,xi,yi,hi,sum=0,ans=0;
scanf("%d%d%d%d",&n,&s,&a,&b);
hi=a+b;
for(int i=1;i<=n;++i)
{
scanf("%d%d",&xi,&yi);
if(xi<=hi)
{
++sum;
c[sum]=yi;
}
}
sort(c+1,c+sum+1);
for(int i=1;s>0;++i)
if(c[i]<=s)
{
++ans;
s-=c[i];
}
printf("%d",ans);
return 0;
}
by jerry3128 @ 2019-10-29 15:02:57
@seer666 第二个循环,i比5000大