DonGDaDa @ 2019-11-24 15:23:58
~~```
int main() { int n,s,a,b,i,j,m,c,d,x; int h[10010]; int e[10010]; scanf("%d%d",&n,&s); scanf("%d%d",&a,&b); for(i=0;i<n;i++) { scanf("%d%d",&h[i],&e[i]); } for(i=1;i<n;i++) { for(j=i;j>=0;j--) { if(e[j]<e[j-1]) { c=h[j]; h[j]=h[j-1]; h[j-1]=c; d=e[j]; e[j]=e[j-1]; e[j-1]=d; } } }
m=0;x=0;
for(i=0;i<n;i++)
{
if(h[i]<=(a+b))
{
m=m+e[i];
x++;
if(m>s)
{
printf("%d",x-1);
break;
}
}
}
return 0;
}
~~
by ThreePlusSeven @ 2019-11-24 15:25:50
@DonGDaDa
by ThreePlusSeven @ 2019-11-24 15:26:15
md炸了 请求重发代码
by 紫陰花 @ 2019-11-24 15:27:51
by DonGDaDa @ 2019-11-24 16:07:09
@ThreePlusSeven 我查清楚情况了,冒泡算法的时候应该是j>0避免了j=0的情况。谢谢了
by Wayward丶 @ 2019-11-25 10:55:04
希丰展,next使MD