Problems
Saddle points
Saddle points
The matrix $A$ is given. It contains $n$ rows and $m$ columns. The \textit{saddle point} of the matrix is an element that is minimum in its row and maximum in its column.
Find the number of saddle points in a given matrix.
\InputFile
The first line contains two integers $n$ and $m\:(1 \le n, m \le 750)$. Then given $n$ rows with $m$ numbers in each. The $j$-th number of the $i$-th line equals $A_{ij}$. All $A_{ij}$ do not exceed $1000$ by absolute value.
\OutputFile
Print the number of saddle points.
\includegraphics{https://eolympusercontent.com/images/seflujhmfd4ih00qc4jtspd6r4.gif}
Input example #1
2 2 0 0 0 0
Output example #1
4
Input example #2
3 4 7 1 5 3 3 2 6 4 5 2 8 6
Output example #2
2