SUMTRAIN PROBLEM(PPLEASE TELL WHERE IS MA ERROR)

#include
using namespace std;
int a[100][100];

int max(int a,int b)
{
     if(a>b)
     return a;
     else
     return b;
}
int main()
{
    int x,y,z,large,sum;
     cin>>x;
 
     for(int i=0;i<x;++i)
     {
         cin>>y;
         for(int i=0;i<y;++i)
         {        sum=0;
               for(int j=0;j<=i;++j)
               {
                                    
                 
                   cin>>a[i][j];
                   
                }
         }

         if(y==1)
         {
           cout<<a[0][0]<<endl;
         }
         else
         {
                for(int i=y-2;i>=0;--i)
                {
                     for(int j=i;j>=0;--j)
                     a[i][j]+=max(a[i+1][j],a[i+1][j+1]);
                 }
         }
         cout<<a[0][0]<<endl;
    }
                     

       
       return 0;
}

Can you please provide a link to the question?

If y==1 u are printing the answer two times.I Added continue at the end of print statement and got AC.Link:http://www.codechef.com/viewsolution/2383265

You are using the same variable name “i” for keeping a tab on no. of test cases & also in taking & processing input. I’d recommend using different variable names. Here’s my code for reference : http://www.codechef.com/viewsolution/2383851

Hope it helps.

Regards,

Ouditchya Sinha.

Here’s the problem link : http://www.codechef.com/problems/SUMTRIAN

thanks bro…got it