#K95412. Matrix Threshold Sum

    ID: 38858 Type: Default 1000ms 256MiB

Matrix Threshold Sum

Matrix Threshold Sum

You are given an \(R \times C\) matrix of integers and an integer threshold \(T\). Your task is to compute the sum of all matrix elements that are strictly greater than \(T\).

The input is provided via standard input (stdin) and the output should be printed to standard output (stdout). First, the dimensions of the matrix are given, followed by the matrix elements, and finally the threshold \(T\) is provided in the last line.

Example:
For a matrix
\(\begin{bmatrix}3 & 5 & 7\\1 & 6 & 8\\4 & 9 & 2\end{bmatrix}\) and threshold \(5\), the valid elements are \(7, 6, 8, 9\) whose sum is \(30\).

inputFormat

The first line contains two space-separated integers (R) and (C), representing the number of rows and columns of the matrix respectively. The next (R) lines each contain (C) space-separated integers representing the matrix rows. The last line contains a single integer (T), the threshold.

outputFormat

Output a single integer – the sum of all matrix elements that are strictly greater than the given threshold (T).## sample

3 3
3 5 7
1 6 8
4 9 2
5
30