IntermediateRating 1200
Negatives in a Sorted Grid
Rows and columns are sorted in non-increasing order. Count the negative numbers in O(r + c).
Input
r c, then r lines.
Output
A count.
Sample 1
Input
4 4 4 3 2 -1 3 2 1 -1 1 1 -1 -2 -1 -1 -2 -3
Output
8
Sample 2
Input
2 2 3 2 1 0
Output
0
Output appears here