Chef and Street Food | CodeChef


My solution gives compiler error, though it perfectly runs on GCC compiler
Here’s my code
#include<stdio.h>
int main()
{
int t, ans = 0, maxi = 0,n;

scanf("%d",&t);
while(t–)
{
scanf("%d",&n);
maxi = 0;
ans = 0;
int a[n][3];
for(int i=0;i<n;i++)
{
for(int j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}
}
for(int i=0;i<n;i++)
{
ans = (a[i][1]/(a[i][0]+1))*a[i][1];
if(ans > maxi)
{
maxi = ans;
}
}
printf("%d\n",maxi);
}
}

You need to initialize the array inside while loop.

1 Like

Whats the reason of doing +1

format your code too!

this doesn’t give compile time error rather it gives WA error btw.

in while loop it should be t–, looks like a typo

no that is because he didn’t format the code :confused:
so – is written like that!

--

see?


How does it work correctly here?
Is there any error in the code?
And, I did +1 for the chef himself.