#C1685. Grid Sum Query
Grid Sum Query
Grid Sum Query
You are given a grid with M rows and N columns. Each cell of the grid contains an integer value. Your task is to compute the sum of all the cells in the grid.
Input: The first line contains two integers M and N (with 1 ≤ M, N ≤ 1000) representing the number of rows and columns respectively. The following M lines each contain N space-separated integers representing the values in the grid.
Output: Output a single integer which is the total sum of all the values in the grid.
Note: While the problem description might hint at querying sub-grids, the optimal solution is to compute the sum by processing the entire grid in one pass.
inputFormat
The input begins with a single line containing two integers M and N separated by a space. The following M lines each contain N space-separated integers representing the grid values.
outputFormat
Output a single integer representing the sum of all the grid cells.
## sample3 4
1 0 1 1
0 1 0 1
1 1 0 0
7