Whats wrong with my code?

I have understood the problem Chef and Street Food and written the solution accordingly link here. I am getting the WA though my solution does exactly same thing as the problem expects, Also, I have referred the official hint and others’ solutions, which has the same logic. So what is causing my code to fail? Please help me to find out the issue, as I tried many times before. Thanks.

Are you reading P and V in the wrong order?

2 Likes

@ssjgz Yes, you are right. Actually I was scanning the values as defined in the order mentioned in the Constraints, but the actual order was different, that caused this thing. Thanks for pointing out the same and saving my day.

1 Like

please check your order respective to this code
#include<stdio.h>
#include<stdlib.h>
int main()
{
int t;
scanf("%d",&t);
for(int i=0;i<t;i++)
{
int n;
scanf("%d",&n);
long int a[100]={0};
for(int k=0;k<n;k++)
{
int s,p,v;
scanf("%d%d%d",&s,&p,&v);
a[k]= (p/(s+1))*v;
}
long int max=a[0];
for(int l=0;l<n;l++)
{
if(max<a[l])
{
max=a[l];
}
}
printf("%d\n",max);
}
return 0;
}