#C3803. Maximum Element in a Matrix

    ID: 47271 Type: Default 1000ms 256MiB

Maximum Element in a Matrix

Maximum Element in a Matrix

You are given a matrix of integers. Your task is to find the maximum path sum in the matrix, where a "path" is defined in a rather unusual way: you may start and end at any cell, and there is no restriction on the number of cells in the path. In addition, each cell can be visited multiple times. With these conditions, it turns out that the maximum sum is simply the maximum element in the matrix, since if there exists any positive element, you would be able to accumulate an arbitrarily high sum. However, as per this problem, you only need to output the maximum value present.

In summary, given a matrix (A) with (m) rows and (n) columns, determine (\max_{0 \le i < m,\ 0 \le j < n} A_{ij}).

inputFormat

The first line contains two space-separated integers (m) and (n) (the number of rows and columns, respectively). This is followed by (m) lines each containing (n) space-separated integers representing the matrix.

outputFormat

Output a single integer — the maximum element of the matrix.## sample

4 4
1 2 3 4
4 5 6 7
7 8 9 10
10 11 12 13
13