#C3942. Calculate Total Garden Water After Updates

    ID: 47425 Type: Default 1000ms 256MiB

Calculate Total Garden Water After Updates

Calculate Total Garden Water After Updates

You are given a garden represented by an \( N \times N \) grid. Each cell in the grid contains an initial water level. There are \( T \) updates; each update specifies a cell located by its row and column indices (0-indexed) and an additional amount of water to add to that cell. After applying all updates, compute the total amount of water needed for the entire garden.

The update operation for a cell \( (r, c) \) with additional water \( W \) is defined as:

[ \texttt{garden}[r][c] = \texttt{garden}[r][c] + W ]

You must read the input from standard input and write the answer to standard output.

inputFormat

The input is given via standard input and has the following format:

  1. The first line contains two space-separated integers: \( N \) and \( T \), where \( N \) is the size of the garden (number of rows and columns) and \( T \) is the number of updates.
  2. The next \( N \) lines each contain \( N \) space-separated integers representing the initial water levels of the garden's cells.
  3. The following \( T \) lines each contain three space-separated integers: \( r \), \( c \), and \( W \), indicating that \( W \) additional units of water are added to the cell at row \( r \) and column \( c \) (0-indexed).

outputFormat

Output a single integer which is the total water required for the entire garden after applying all updates.

## sample
3 2
1 2 3
4 5 6
7 8 9
0 0 10
2 2 5
60