CF157A.Game Outcome

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Sherlock Holmes and Dr. Watson played some game on a checkered board n×nn×n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.

For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8+3+6+7=248+3+6+7=24 , sum of its row numbers equals 9+5+3+2=199+5+3+2=19 , and 24>19 .

输入格式

The first line contains an integer nn ( 1<=n<=301<=n<=30 ). Each of the following nn lines contain nn space-separated integers. The jj -th number on the ii -th line represents the number on the square that belongs to the jj -th column and the ii -th row on the board. All number on the board are integers from 11 to 100100 .

输出格式

Print the single number — the number of the winning squares.

输入输出样例

  • 输入#1

    1
    1
    

    输出#1

    0
    
  • 输入#2

    2
    1 2
    3 4
    

    输出#2

    2
    
  • 输入#3

    4
    5 7 8 4
    9 5 3 2
    1 6 6 4
    9 5 7 3
    

    输出#3

    6
    

说明/提示

In the first example two upper squares are winning.

In the third example three left squares in the both middle rows are winning:

5 7 8 4<br></br><span class="tex-font-style-bf"><span class="tex-font-style-it"> $9$ $5$ $3$ </span></span> 2<br></br><span class="tex-font-style-bf"><span class="tex-font-style-it"> $1$ $6$ $6$ </span></span> 4<br></br>9 5 7 3<br></br>

首页