I was solving a problem which is NONNEGPROD Problem - CodeChef
in this problem, I am supposed to take input inside the array of a given length & with the multiplication of all array elements. I need to print the output that how many elements do I need to remove for multiplication>0.
#include <stdio.h>
int main(void)
{
int t,n;
scanf("%d",&t);
for(int i=0;i<t;i++)
{
scanf("%d",&n);
int a[n],mul=1;
for(int j=0;j<n;j++)
{
scanf("%d",&a[j]);
mul=mul*a[j];
}
if(mul<0)
{
printf("1\n");
}
else
{
printf("0\n");
}
}
return 0;
}
so it was my logic. I am multiplying the array elements while entering them & I compare the final multiplication as if it is less than 0, equal to 0 or grater than 0 but when I submit CodeChef shows me “Wrong Answer” which must be a mistake.