You are not logged in. Please login at www.codechef.com to post your questions!

×

[closed] getting wrong ans

include<stdio.h>

include<conio.h>

int tri(int,int,int); int a[100][100]; int s1,s2,val;

main()
{
    int n,m,i,j,sum,k;
    scanf("%d",&m);
    for(k=1;k<=m;k++)
    {
        scanf("%d",&n);

        for(i=0;i<n;i++)
        {
            for(j=0;j<=i;j++)
            scanf("%d",&a[i][j]);
            printf("\n");

        }
sum=tri(0,0,n);
printf("%d\n",sum);
    }

getch();

}

int tri(int i,int j,int n) { if(i>=(n-1)) { val= a[i][j];} else { s1=a[i][j]+tri(i+1,j,n); s2=a[i][j]+tri(i+1,j+1,n); if(s1>s2) val=s1; val=s2; } return val;

}

asked 08 Aug '14, 18:01

sarique's gravatar image

1★sarique
-1119
accept rate: 0%

closed 08 Aug '14, 18:42

kcahdog's gravatar image

3★kcahdog
10.0k2854129

The question has been closed for the following reason "Duplicate Question" by kcahdog 08 Aug '14, 18:42

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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:

×849
×334
×135
×30
×24
×9

question asked: 08 Aug '14, 18:01

question was seen: 538 times

last updated: 08 Aug '14, 18:42