fork download
  1. #include<iostream>
  2. using namespace std;
  3. #define F(x,y) for(x=1;x<=y;x++)
  4. int main(){int a[101][101],t,n,x,l,i,j,k;cin>>t;F(i,t){cin>>n;l=0;F(j,n)F(k,j){cin>>x;a[j][k]=max(a[j-1][k],a[j-1][k-1])+x;l=max(l,a[j][k]);}cout<<l<<endl;} return 0;}
  5.  
Success #stdin #stdout 0s 3100KB
stdin
2
3
1
2 1
1 2 3
4 
1 
1 2 
4 1 2
2 3 1 1 
stdout
5
9