LOSTWEKD CODECHEF IDE

#include<stdio.h>
int main()
{
int t;
int i,a[5],p,sum=0;
scanf("%d", &t);
while(t–>0)
{
for(i=1;i<=5;i++)
{
scanf("%d", &a[i]);

    }
    scanf("%d", &p);
    
    for(i=1;i<=5;i++)
    {
        sum=sum+a[i]*p;
    }
    if(sum>120)
    {
        printf("YES\n");
        printf("\n");
    }
    else
    {
        printf("NO\n");
        printf("\n");
    }
    sum=0;
}
return 0;

}

When I run this code in my IDE it is running . When I run it on CodeChef IDE I am getting a WA

Thank you for your reply.Although i have removed ‘\n’ it is showing wrong answer.

change YES to Yes and NO to No. Your will code will run.

1 Like

Your array size is 5 and indexing should start from zero for the same. But if have take indexing from 1 then size should n+1 i.e 6 in this case. Correct it and resubmit.

Thank you so much. It worked.

I think this should be t>0 and you should decrement the value of t in this while loop .

No, their code is actually while (t-->0), but they didn’t format it so it got messed up

1 Like

You should change YES to Yes and NO to No, otherwise your output would be considered wrong

1 Like