GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Tuesday, 10 May 2022

X-Sum Codeforces Solution | Codeforces Problem Solution 2022

D. X-Sum
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Timur's grandfather gifted him a chessboard to practice his chess skills. This chessboard is a grid a with n rows and m columns with each cell having a non-negative integer written on it.

Timur's challenge is to place a bishop on the board such that the sum of all cells attacked by the bishop is maximal. The bishop attacks in all directions diagonally, and there is no limit to the distance which the bishop can attack. Note that the cell on which the bishop is placed is also considered attacked. Help him find the maximal sum he can get.

Solution Click Below:-  CLICK HERE


Input

The first line of the input contains a single integer t (1t1000) — the number of test cases. The description of test cases follows.

Most Similar Words Codeforces Solution

The first line of each test case contains the integers n and m (1n2001m200).

The following n lines contain m integers each, the j-th element of the i-th line aij is the number written in the j-th cell of the i-th row (0aij106)

It is guaranteed that the sum of nm over all test cases does not exceed 4104.

Output

For each test case output a single integer, the maximum sum over all possible placements of the bishop.


Join Now for Solution:- 

No comments:

Post a Comment