Time limit
2s
Memory limit
128 MB
When nine numbers are sorted, the median is the fifth number.
Image I is a two-dimensional array of pixels with size R × C. Each pixel stores a darkness value V, where 0 ≤ V ≤ 255. Both R and C are between 3 and 40, inclusive.
A 3 × 3 median filter slides over the image starting at the upper-left corner, moving right, then continuing from the next row. At each position, the nine covered pixel values are sorted and the median becomes one pixel of the filtered image J. Therefore, J has size (R - 2) × (C - 2).
Given image I and a threshold T, count how many pixels in J have value greater than or equal to T.
The first line contains R and C. Each of the next R lines contains C pixel values for one row of the image. The last line contains the threshold T.
Print the number of pixels in the filtered image J whose value is greater than or equal to T.