Rook Attack

4.2

5 votes
, C++, Basic Programming
Problem

Given a  chessboard, where every cell has a value assigned to it denoted by (Cell in the row from top and column from left).

Find the position where we should place the rook, just the sum of cells which are under attack of rook is maximum possible. The rook can not attack the cell on which it is placed.

If there are more than one positions for , return the position where is as minimum as possible. If there are more than one positions with equal , return the position where is as minimum as possible.

Note:

  • based indexing is followed.
  • A rook can attack all the cells which are either in horizontal or vertical direction to the rook's position.

Input

  • First line contains two space separated integers denoting  and .
  • Next lines contains space separated integers denoting the values of array .

Output

Print two space separated integers denoting the rook's position.

Constrains

 

Sample Input
2 2
4 1 
3 1
Sample Output
1 2
Time Limit: 1.5
Memory Limit: 256
Source Limit:
Explanation
  • If we place the rook at (1, 2) position, the cells under attack of rook will be
    • (1, 1), (2, 2)
  • The sum of these cells will be
    • 4 + 1 = 5, which is maximum possible.
Editor Image

?