View Code of Problem 65

#include<bits/stdc++.h>
using namespace std;
int main(){    
        	int n,t;
        	scanf("%d",&n);
        	while(n--){
        		int a[1000][1000]={ };
        		scanf("%d",&t);
        		for(int i =0;i<t;i++){
        			for(int j = 0;j<=i;j++)
        				scanf("%d",&a[i][j]);
				}
        		for(int i = t-1;i>=0;i--){
        			for(int j = 0;j<=i;j++){
        				if(a[i][j]>a[i][j+1]) a[i-1][j] = a[i-1][j]+a[i][j];
        				else a[i-1][j] = a[i-1][j]+a[i][j+1];
					}
				}
        		cout<<a[0][0]<<endl;
			}
        	return 0;
        }


Double click to view unformatted code.


Back to problem 65