21 lines
600 B
Java
21 lines
600 B
Java
import java.util.*;
|
|
|
|
public class _1932 {
|
|
public static void main(String[] args) {
|
|
Scanner sc = new Scanner(System.in);
|
|
int n = Integer.parseInt(sc.nextLine());
|
|
int[][] nums = new int[n][];
|
|
for(int i=0; i<n; i++) {
|
|
nums[i] = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer :: parseInt).toArray();
|
|
}
|
|
sc.close();
|
|
|
|
for(int i=n-2; i>=0; i--) {
|
|
for(int j=0; j<=i; j++) {
|
|
nums[i][j] += Math.max(nums[i+1][j],nums[i+1][j+1]);
|
|
}
|
|
}
|
|
System.out.println(nums[0][0]);
|
|
}
|
|
}
|