#K93327. Warehouse Inventory Update and Range Checker

    ID: 38395 Type: Default 1000ms 256MiB

Warehouse Inventory Update and Range Checker

Warehouse Inventory Update and Range Checker

You are given a warehouse represented by a M×N matrix. Each cell in the matrix contains an inventory quantity. You will receive Q update operations. In each update, you add a given value to a specified cell of the matrix. After every update, your task is to check if the range of the matrix, defined as

\(\text{range} = \max_{i,j}\;A_{i,j} - \min_{i,j}\;A_{i,j}\)

exceeds a predefined limit L. If it does, print YES; otherwise, print NO.

Note that the matrix indices in the update operations use 1-indexing.

inputFormat

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

  1. The first line contains three space-separated integers: M (number of rows), N (number of columns), and L (the range limit).
  2. The second line contains M*N space-separated integers representing the initial quantities in the matrix in row-major order.
  3. The third line contains a single integer Q, the number of updates.
  4. Each of the next Q lines contains three space-separated integers: r, c, and v, where r and c denote the 1-indexed row and column to be updated, and v is the value to be added to that cell.

outputFormat

For each update operation, output a single line. The line should be YES if after the update the difference between the maximum and minimum elements in the matrix is strictly greater than L and NO otherwise.

The output is printed to standard output (stdout).

## sample
2 2 5
1 2 3 4
3
1 1 5
2 2 2
1 2 6
NO

NO YES

</p>