308. Negatives in a Sorted Matrix
EasyStaircase
Rows and columns are sorted in non-increasing order. Print how many negative numbers the matrix contains.
Input format
Line 1: r c Next r lines: c integers
Output format
The count.
Example 1
Input
4 4 4 3 2 -1 3 2 1 -1 1 1 -1 -2 -1 -1 -2 -3
Output
8
Example 2
Input
2 2 3 2 1 0
Output
0
Constraints
1 ≤ r, c ≤ 1000
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…