trianglesum

Some crazy guy shows you a n x n grid of integers.

He then asks you to find the maximum value of the sum of all integers inside any k x k northwest oriented right angled triangle in the grid.

The k x k triangle must reside FULLY in the grid.

Being a smart programmer, you decide to use a computer to solve the madman's question.

Input

The first line of input will consist of 2 integers n (1 ≤ n ≤ 5,000) and k (1 ≤ kn).

The following n lines will contain n integers each. Each integer a will satisfy 1 ≤ a ≤ 400.

Output

Output the maximum sum possible as described above.

Grading

For 20% of the test cases, n ≤ 50.

For 50% of the cases (including the above 20%), n ≤ 300.

Sample Input 1

5 3
1 2 3 1 3
3 1 1 1 4
1 2 3 1 5
5 5 5 5 5
5 5 3 5 5

Sample Output 1

22

Explanation for Sample Output 1

The k x k northwest oriented right angled triangle that gives the maximum sum is this portion:

3 1 5
5 5
3

which gives 22.

Notice that the incomplete triangle bit which gives a better sum of 23:

5 5 5
3 5

is not allowed.



Submitting .cpp to 'trianglesum'


You're not logged in! Click here to login

Time Limit: 4 Seconds
Memory Limit: 1024MB
Your best score: 0
Source: NOI 2010 Selection Test

Subtask Score
1 20
2 30
3 50
4 0