×

# Figuring out Wrong test case

iam not being able to figure out the wrong test case in my code for the problem https://www.codechef.com/problems/PPTEST can anyone help? my code goes out like this

# include <stdlib.h>

int max(int a ,int b)

{

if(a>b)

return a;

else

return b;

}

int main()

{

int t,n,w,testcase,i,j; int g[101][101]; int a[101][101]; int b[101][101];

scanf("%d",&t);

for(testcase=1;testcase<=t;testcase++)

{

scanf("%d %d",&n,&w);

for(i=1;i<=n;i++)

{

for(j=1;j<=3;j++)

{

scanf("%d",&g[i][j]);

}

}

for(i=1;i<=n;i++)

{

for(j=1;j<=w;j++)

{

if(i==1)

{

if(j>=g[i][3])

{

a[i][j]=g[i][1]*g[i][2];

b[i][j]=g[i][3];

}

else

{

a[i][j]=0;

b[i][j]=0;

                 }


}

else if(j>=g[i][3])

{

if(g[i][3]+b[i-1][j]<=w)

{

a[i][j]=max(((g[i][1]g[i][2])+a[i-1][j]),g[i][1]g[i][2]);

b[i][j]=g[i][3]+b[i-1][j];

}

else

{

a[i][j]=a[i-1][j];

b[i][j]=b[i-1][j];

}

}

else

{

a[i][j]=a[i-1][j];

b[i][j]=b[i-1][j];

}

}

}

printf("%d\n",a[n][w]);

}

return 0;

}

212
accept rate: 0%

 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×2,167

question asked: 29 Jul '15, 19:32

question was seen: 333 times

last updated: 29 Jul '15, 19:32