Koi Sense Hai Iss baat ki? Uss time bhut lag rhi thi!

0

0 votes
Problem

Given a  2D Array:

1 1 1 0 0 0
0 1 0 0 0 0
1 1 1 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0

An hourglass in arr is a subset of values with indices falling in this pattern in arr's graphical representation:

a b c
  d
e f g

There are 16 hourglasses in arr. An hourglass sum is the sum of an hourglass' values. Calculate the hourglass sum for every hourglass in arr, then print the maximum hourglass sum. The array will always be 6 X 6.

 

Input Format

Each of the lines of inputs contains space-separated integers.

Constraints

  • -9 <= arr[I][j] <= 9
  • 0 <= I,j <= 5

Output Format

Print the largest (maximum) hourglass sum found in arr.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

 arr contains the following hourglasses:

image

The hourglass with the maximum sum (19) is:

2 4 4
  2
1 2 4
Editor Image

?