problem link:

all the sample input for the code are right for the problem but it showing WA after the submission plz help

#include<stdio.h>

main()

{

int t,i,j,sale[100],max,s,p,v,n;

scanf(“%d”,&t);

for(i=0;i<t;i++)

{

scanf(“%d”,&n);

for(j=0;j<n;j++)

{

scanf(“%d %d %d”,&s,&p,&v);

sale[j]=(p/(s+1)*v);

}

max=sale[0];

for(j=0;j<n-1;j++)

{

if(sale[j+1]>sale[j])

{

max=sale[j+1];

}

}

printf(“%d”,max);

}

}

HERE YOU GO.

```
#include<stdio.h>
main()
{
long long int t,i,j,sale[102],max,s,p,v,n;
scanf("%lld",&t);
for(i=0;i<t;i++)
{
scanf("%lld",&n);
for(j=0;j<n;j++)
{
scanf("%lld %lld %lld",&s,&p,&v);
sale[j]=(int((p/(s+1)))*v);
}
max=sale[0];
for(j=0;j<n-1;j++)
{
if(sale[j+1]>max)
{
max=sale[j+1];
}
}
printf("%lld\n",max);
}
}
```

the only problem is that you used int data type and the last “if” condition was wrong.

try coding out this logic

python code:

# cook your dish here

t=int(input())

for _ in range(t):

n=int(input())

arr=[]

for i in range(n):

s,p,v=map(int,input().split())

res=(p//(s+1))*v

arr.append(res)

#print(arr)

print(max(arr))

I am getting wrong answer if i use the following logic:

scanf("%d %d %d",&s,&p,&v);

prof=(v/(s+1)*p);

what’s wrong with this?

bro this problem arises due to the priority of the mathematical equation which makes the division to take place first then the multiplication thus causing error

hey how that equation came pls explain me this anyone??

It’s showing WA, can somebody please tell what’s wrong with this code:-

t = int(input())

ans = []

for i in range(t):

arr = []

n = int(input())

for j in range(n):

S,V,P = map(int, input().strip().split())

A = (P//(S+1)) * V

arr.append(A)

ans.append(max(arr))

for i in ans:

print(i)