yzr2009 @ 2021-01-30 22:02:09
#include<bits/stdc++.h>
using namespace std;
int n,s,a,b,x[5001],y[5001],num,h,flag[5001];
int main()
{
int i;
cin>>n>>s>>a>>b;
for(i=1;i<=n;i++)
cin>>x[i]>>y[i];
h=a+b;
for(i=1;i<=n;i++)
{
if(h>=x[i])
flag[i]=1;
}
sort(y+1,y+n+1);
for(i=1;i<=n;i++)
if(flag[i]==1&&s>=y[i])
{
s=s-y[i];
num++;
if(s<0)
break;
}
cout<<num<<endl;
return 0;
}
by ycr_qwq @ 2021-02-01 20:00:24
if(s<0)
break;
变成
if(s<=0)
break;
by ycr_qwq @ 2021-02-01 20:01:17
试一下\ 因为ta0的时候也不可以
by yzr2009 @ 2021-02-02 19:56:45
@tangwulin666 还是一样的,80分