Choosing a Diverging Colormap
Brindle & Co's regional grid shows each store's change against last year: positive where it grew, negative where it shrank. The chart uses a two-ended colour scale so growth and decline read as different colours rather than as darker and lighter shades of one. The regional director wants the count of losses stated plainly at the top of the page.
Task: Print how many cells in the grid hold a negative value.
Input
The first line holds two integers separated by a single space: how many rows the grid has, then how many columns, each between 1 and 100. Then come that many rows, each holding that many numbers separated by single spaces.
Output
One line holding a whole number: how many cells are below zero. A cell holding exactly zero is flat, not a loss, and is not counted.
Example:
Input:
2 2
-1 2
-3 4
Output:
2
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in