ayf049 edited 18 小时前
为什么会在第八个测试点才出错呢
#include<stdio.h>
int main(){
int n=0,i=0,work=0,aim=0,hard=0,maxium=0,index=0,day=0;
int a[9999999],b[9999999],t[9999999],c[9999999],m[9999999];
scanf("%d",&n);
day=n;
for(i=0;i<n;i++)
{
scanf("%d %d %d",&t[i],&a[i],&b[i]);
c[i]=a[i]-b[i];
work+=b[i];
aim+=t[i];
hard+=a[i];
}
if(work>=aim)
{
printf("%d",n);
}
else if(hard<aim)
{
printf("-1");
}
else{
work=0;
while(work<aim)
{
maxium=c[0];
for(int i=1;i<=n;i++)
{
if(c[i]>maxium)
{
maxium=c[i];
index=i;
c[i]=0;
}
}
work+=maxium;
day--;
}
printf("%d",day+1);
}
return 0;
}