LinGxIao_0230 @ 2019-11-13 21:04:22
#include<bits/stdc++.h>
using namespace std;
long long a,b,k,s,n,t=-1,x[5005],y[5005];
int main()
{
cin>>n>>s>>a>>b;
for(int i=1;i<=n;i++) cin>>x[i]>>y[i];
for(int i=1;i<=n;i++)
{
for(int j=i;j<=n;j++)
{
if(y[i]>y[j])
{
swap(y[i],y[j]);
swap(x[i],x[j]);
}
}
}
for(int i=1;i<=n;i++)
{
if(s<0) break;
else if(x[i]<=a+b)
{
t++;
s-=y[i];
}
}
cout<<t;
return 0;
}
by LinGxIao_0230 @ 2019-11-13 21:04:55
苹果摘淘淘
by an_jin @ 2019-11-13 21:30:06
s==0的时候应该cout<<0
然而你的是-1