import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int arr[][] = new int[n+2][n+2];
int f[][] = new int[n+2][n+2];
for (int i = 0; i<=n; i++){
arr[i][i+1] = 0;
}
for (int i = 1; i<=n; i++){
for (int j = 1; j<=i; j++){
arr[i][j] = in.nextInt();
}
}
for (int i = 1; i<=n; i++){
f[n][i] = arr[n][i];
}
for (int i =n-1; i>0; i--){
for (int j = 1; j<=n; j++){
f[i][j] = Math.max(f[i+1][j], f[i+1][j+1])+arr[i][j];
}
}
System.out.println(f[1][1]);
in.close();
}
}
我的输入输出
input:
答案错误:您提交的程序没有通过所有的测试用例
测试用例:
1
100
对应输出应该为:
100
能不能把我的程序在你的机子上run的结果给我看下,让我知道究竟差别在哪里,什么叫对应输出的应该为100,那我输出的不就是100吗?