CF——Game Outcome

                                                                                                                  Game Outcome

Description

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 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 = 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.

Sample Input

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

Hint

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 4953 2166 49 5 7 3

 

就是找列向量的和大于行向量和的总个数

 

#include <stdio.h>


int main()
{
    int n,i,j,m,k,sum;
    int hh[50];
    int lh[50];
    int mapp[50][50];

    scanf("%d",&n);
    for(i = 0;i < n;i++)
    {
        sum = 0;
        for(j = 0;j < n;j++)
        {
            scanf("%d",&mapp[i][j]);
            sum += mapp[i][j];
        }
        hh[i] = sum;
    }
    for(i = 0;i < n;i++)
    {
        sum = 0;
        for(j = 0;j < n;j++)
        {
            sum += mapp[j][i];
        }
        lh[i] = sum;
    }
    for(i = 0;i < n;i++)
    {
        for(j = 0;j < n-1-i;j++)
        {
            if(hh[j] < hh[j+1])
            {
                k = hh[j];
                hh[j] = hh[j+1];
                hh[j+1] = k;
            }
        }
    }
    int num = 0;
    for(i = 0;i < n;i++)
    {
        m = lh[i];
        for(j = 0;j < n;j++)
        {
            if(m > hh[j])
            {
                num = num + (n - j);
                break;
            }
        }
    }
    printf("%d\n",num);
    return 0;
}


 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
mag_outcome是一个英文单词,意思是"魔法的结果"。在魔法的世界中,mag_outcome指的是魔法施法者使用魔法后所产生的效果或影响。 首先,mag_outcome的结果可以是积极的。当魔法施法者使用魔法时,他们可以实现各种奇妙的事情。这些包括但不限于恢复伤口、治愈疾病、制造食物、创造物品等等。这种积极的结果可以帮助人们改善生活,解决问题,甚至拯救生命。 然而,mag_outcome的结果也可能是负面的。魔法力量具有很大的破坏性,如果魔法施法者不慎使用魔法,可能会导致意想不到的后果。例如,错误的咒语可能会导致爆炸、火灾或其他灾难性事件的发生。此外,有时使用魔法可能会破坏自然平衡,导致环境的损害或其他不良影响。 除了积极和负面的结果之外,mag_outcome也可能是中性的。有时魔法的影响可能并不直接带来好处或伤害,但仍然对施法者或周围的环境产生一定的改变。例如,一些魔法可能会改变人的外貌,提高智力或增强某些技能,这些影响可能既不是积极的也不是负面的,而只是改变了现状。 总而言之,mag_outcome指的是魔法施法者使用魔法后所产生的效果或影响。这些结果可能是积极的、负面的或中性的,它们可以改善生活,但也可能导致意外的后果。在使用魔法时,施法者应该小心谨慎,以确保达到期望的结果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值