a871525261 @ 2019-10-03 21:07:33
int main()
{
int n,s,a,b,i,j,temp,sum;
int gao[5000]={0};
int li[5000]={0};
scanf("%d %d",&n,&s);
scanf("%d %d",&a,&b);
for(i=0;i<n;i++){
scanf("%d %d",&gao[i],&li[i]);
}
for(i=0;i<n-1;i++){
for(j=0;j<n-1-i;j++){
if(li[j]>li[j+1]){
temp=li[j];
li[j]=li[j+1];
li[j+1]=temp;
temp=gao[j];
gao[j]=gao[j+1];
gao[j+1]=temp;
}
}
}
for(i=0;i<n;i++){
if(a+b>=gao[i]){
s=s-li[i];
if(s>=0){
sum++;
}
else{
printf("%d",sum);
return 0;
}
}
}
printf("%d",sum);
return 0;
}
by Eric_lerk @ 2019-10-03 21:25:07
@冥诺在线发呆 掏了掏了
by a871525261 @ 2019-10-03 21:25:43
@冥诺在线发呆 ??样例我运行是过的呀,输出4
by 冥诺在线发呆 @ 2019-10-03 21:26:25
@a871525261 sum没初始化
by a871525261 @ 2019-10-03 21:27:38
@冥诺在线发呆 还真是。。。感谢老哥