1836796ad @ 2018-07-31 11:11:56
请各位神犇看看,到底哪里错了:
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e=0,f[101],g[101],h[101],j=0,k=0,l=1,m=1;
int main()
{cin>>a>>b;
cin>>c>>d;
for (int i=1; i<=a; i++)
{
cin>>f[i]>>g[i];
}
j=c+d;
for (int i=1; i<=a; i++)
{
if(f[i]<=j)
{
h[l]=g[i];
l++;
e++;
}
}
sort(h,h+(e+1));
for (;;)
{
if(b<0)
{
break;
}
else
{
b=b-h[m];
k++;
m++;
}
}
if(k==0)
{
cout<<"0";
}
else
{
cout<<k-1;
}
return 0;
}
by Edwinlau @ 2018-07-31 11:33:04
你用了无循
by TERRYXU @ 2018-08-01 10:51:15
第三个循环有问题你调一下就看出来了