# CodeForces 157A Game Outcome

A. Game Outcome

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Sherlock Holmes and Dr. Watson played some game on a checkered board n × 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 consideredwinning 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 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 > 19.

Input

The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100.

Output

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

Examples

input

```1
1```

output

`0`

input

```2
1 2
3 4```

output

`2`

input

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

output

6

```#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;
int r[35];
int l[35];
int a[35][35];
int n;
int main()
{
scanf("%d",&n);
memset(r,0,sizeof(r));
memset(l,0,sizeof(l));
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
scanf("%d",&a[i][j]);

}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
r[i]+=a[i][j];
l[i]+=a[j][i];
}
}
int num=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(l[j]>r[i])
num++;
}
}
printf("%d\n",num);
return 0;
}```

0 条评论

• ### POJ-1276-Cash Machine（多重背包）

Cash Machine Time Limit: 1000MS Memory Limit: 10000K Total Submissions:...

• ### ZOJ 3202 Second-price Auction

Time Limit: 1 Second      Memory Limit: 32768 KB

• ### CodeForces 665B Shopping

B. Shopping time limit per test 1 second memory limit per test 256 megabyt...

• ### IOS5开发-控件位置适应屏幕旋转代码

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toOrientation  ...

• ### Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)(A.暴力，B.优先队列，C．dp乱搞)

A. Carrot Cakes time limit per test：1 second memory limit per test：256 megabytes...

• ### Ceph用户邮件列表Vol45-Issue3

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=af5e5...

• ### 周练19.11.03/10

它表示一个迷宫，其中的1表示墙壁，0表示可以走的路，只能横着走或竖着走，不能斜着走，要求编程序找出从左上角到右下角的最短路线。

• ### 机器人控制器编程课程-教案02-基础

版权声明：本文为博主原创文章，遵循 CC 4.0 BY-SA 版权协议，转载请附上原文出处链接和本声明。

• ### hdu---(1800)Flying to the Mars(trie树)

Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768...

• ### POJ 1012 Joseph

Joseph Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 53862 ...