Abdul and Apples

4.4

7 votes
Problem

Abdul and apples

There is a rectangular field of apple trees of size NxM. Abdul is very fond of apples. He wants to collect as many apples as possible. But the owner of the apple field ,Shivam,is super duper smart. He has planted some poisonous trees and he allows Abdul to collect apples on one condition. Abdul can select one square field of apple trees of any size. As some trees are poisonous, they can be said to be negetive apples. Help Abdul maximise the total number of apples. As Abdul is very greedy, he has to pick atleast one tree.

INPUT: First line will consist of the number of test caes.

The next line will have two integers : the number of rows R and coloums C in the field.

The next R lines will have C integers each representing number of apples on each tree in that row.

OUTPUT: One integer representing the maximum number of apples possible to collect

Constraints:

1<= R,C <=100
-10^9<= number of apples <=10^9

Problem Setter :
Shivam Beri
Problem Tester:
Teja Vojjala

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

The largest sum of square we can choose is :
2 3 4 5
-2 -3 -4 5
-1 5 -3 -1
5 -10 7 -1

which has a sum of 11.

Editor Image

?