#C7497. Find the Maximum Value Cell
Find the Maximum Value Cell
Find the Maximum Value Cell
You are given a grid (2D array) of integers. Your task is to find the cell that contains the maximum value. In the case where multiple cells have the same maximum value, return the coordinates of the cell that appears first in row-major order.
In other words, if the maximum value appears several times, choose the one with the smallest row index; if there is still a tie, choose the one with the smallest column index.
Note: The indices are 0-based. That is, the top-left cell is (0, 0).
The maximum value can be represented by the formula: \(\max_{0\leq i<m,\,0\leq j<n} A_{i,j}\).
inputFormat
The first line contains two integers \(m\) and \(n\) (number of rows and columns respectively). Each of the following \(m\) lines contains \(n\) space-separated integers representing the grid.
outputFormat
Output two integers separated by a space: the row index and column index of the cell having the maximum value. If there are multiple cells with the maximum value, output the coordinates of the first occurrence in row-major order.
## sample1 3
3 1 2
0 0