2017-02-16 23:51:56 -06:00
|
|
|
// Author: Rodney Shaghoulian
|
2018-07-27 16:45:56 -07:00
|
|
|
// Github: github.com/RodneyShag
|
|
|
|
|
// HackerRank: hackerrank.com/RodneyShag
|
2017-02-16 23:51:56 -06:00
|
|
|
|
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
|
|
public class Solution {
|
2017-09-11 09:32:17 -07:00
|
|
|
public static void main(String[] args) {
|
2017-02-16 23:51:56 -06:00
|
|
|
Scanner scan = new Scanner(System.in);
|
|
|
|
|
int arr[][] = new int[6][6];
|
|
|
|
|
for (int row = 0; row < 6; row++) {
|
|
|
|
|
for (int col = 0; col < 6; col++) {
|
|
|
|
|
arr[row][col] = scan.nextInt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
scan.close();
|
|
|
|
|
|
|
|
|
|
System.out.println(maxHourglass(arr));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int maxHourglass(int [][] arr) {
|
|
|
|
|
int max = Integer.MIN_VALUE;
|
|
|
|
|
for (int row = 0; row < 4; row++) {
|
|
|
|
|
for (int col = 0; col < 4; col++) {
|
|
|
|
|
int sum = findSum(arr, row, col);
|
|
|
|
|
max = Math.max(max, sum);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return max;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static int findSum(int [][] arr, int r, int c) {
|
|
|
|
|
int sum = arr[r+0][c+0] + arr[r+0][c+1] + arr[r+0][c+2]
|
|
|
|
|
+ arr[r+1][c+1] +
|
|
|
|
|
arr[r+2][c+0] + arr[r+2][c+1] + arr[r+2][c+2];
|
|
|
|
|
return sum;
|
|
|
|
|
}
|
|
|
|
|
}
|