Skip to content

Instantly share code, notes, and snippets.

@mccraveiro mccraveiro/sumitr.c
Created Jun 15, 2012

Embed
What would you like to do?
#define s(v) scanf("%d",&v);
#define a p[r][c]
int main(){int n,i,r,c,l,m,p[100][100];s(n)for(i=0;i<n;i++){s(l)m=0;for(r=0;r<l;r++)for(c=0;c<=r;c++){s(a)if(r!=0){a+=(c==0||p[r-1][c-1]<=p[r-1][c])?p[r-1][c]:p[r-1][c-1];if(r+1==l)m=a>m?a:m;}}printf("%d\n",m);}}
@nehaljwani

This comment has been minimized.

Copy link

commented Jun 26, 2012

define f(a,c) for(a=1;a<=c;a++)

define s(v) scanf("%d",&v)

int max(a,b){return a>b?a:b;}
main(){int s,n,i,j,x,t[101][101];s(s);while(s--){x=0;s(n);f(i,n)f(j,i)s(t[i][j]),x=(t[i][j]+=max(t[i-1][j-1],t[i-1][j]))>x?t[i][j]:x;printf("%d\n",x);}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.