Submission issue of STfood

#include
using namespace std;
int main()
{
int t,i,j,n,m=0,z;
cin>>t;
for(i=0;i<t;i++)
{
cin>>n;
for(j=0;j<n;j++)
{
int s,p,v;
cin>>s>>p>>v;
z=(p/(s+1))*v;
if(z>m)
m=z;
}
cout<<“max is”<<m;
}
return 0;
}

it is not submitting… it is showing wrong answer …

delete this

Yepp, only print m

Print as shown in custom input i.e eg

#include
using namespace std;
int main()
{
int t,i,j,n,m=0,z;
cin>>t;
for(i=0;i<t;i++)
{
cin>>n;
for(j=0;j<n;j++)
{
int s,p,v;
cin>>s>>p>>v;
z=(p/(s+1))*v;
if(z>m)
m=z;
}
cout<<m;
}
return 0;
}

still submission failed …

cout << m << endl;

:slight_smile:

1 Like

#include
using namespace std;
int main()
{
int t,i,j,n,m=0,z;
cin>>t;
for(i=0;i<t;i++)
{
cin>>n;
for(j=0;j<n;j++)
{
int s,p,v;
cin>>s>>p>>v;
z=(p/(s+1))*v;
if(z>m)
m=z;
}
cout<<m<<endl;
}
return 0;
}

the following code is running properly in turbo c++ but it is showing wrong answer in code chef submission page.

This solution: https://www.codechef.com/viewsolution/29249190 fails the testcase:

2
1
1 2 100
1
1 2 10
1 Like

Should not the Initialisation of m=0 be inside the first for loop?

Yes
After each testcase , you are not changing the value of m = 0
change that and you will get AC
:slight_smile: