import java.util.Scanner; public class main1 { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int p=scanner.nextInt(); while (p-->0) { int n=scanner.nextInt(); int dp[][]=new int[n][n]; dp[0][0]=scanner.nextInt(); int max=0; for (int i = 1; i < dp.length; i++) { for (int j = 0; j <= i; j++) { int num=scanner.nextInt(); if (j==0) { dp[i][j]=dp[i-1][j]+num; }else { dp[i][j]=Math.max(dp[i-1][j], dp[i-1][j-1])+num; } max=Math.max(max, dp[i][j]); } } System.out.println(max); } } }
0.0分
1 人评分