Created
June 15, 2012 00:36
-
-
Save mccraveiro/2933907 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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);}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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);}}