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;
}

CodeForces 157A Game Outcome的更多相关文章

  1. CodeForces 451C Predict Outcome of the Game

    Predict Outcome of the Game Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d &a ...

  2. codeforces 258div2C Predict Outcome of the Game

    题目链接:http://codeforces.com/contest/451/problem/C 解题报告:三个球队之间一共有n场比赛,现在已经进行了k场,不知道每个球队的胜场是多少,如三个球队的胜场 ...

  3. codeforces 451C. Predict Outcome of the Game 解题报告

    题目链接:http://codeforces.com/problemset/problem/451/C 题目意思:有3支球队(假设编号为1.2.3),总共要打 n 场比赛,已知已经错过这n场比赛中的 ...

  4. OUC_Summer Training_ DIV2_#5

    这是做的最好的一次了一共做了4道题  嘻嘻~ A - Game Outcome Time Limit:2000MS     Memory Limit:262144KB     64bit IO For ...

  5. Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game 水题

    C. Predict Outcome of the Game 题目连接: http://codeforces.com/contest/451/problem/C Description There a ...

  6. Codeforces Round #258 (Div. 2/C)/Codeforces451C_Predict Outcome of the Game(枚举)

    解题报告 http://blog.csdn.net/juncoder/article/details/38102391 题意: n场比赛当中k场是没看过的,对于这k场比赛,a,b,c三队赢的场次的关系 ...

  7. CF451C Predict Outcome of the Game 水题

    Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...

  8. Codeforces Round #379 (Div. 2) A. Anton and Danik 水题

    A. Anton and Danik 题目连接: http://codeforces.com/contest/734/problem/A Description Anton likes to play ...

  9. [codeforces 293]A. Weird Game

    [codeforces 293]A. Weird Game 试题描述 Yaroslav, Andrey and Roman can play cubes for hours and hours. Bu ...

随机推荐

  1. int.TryParse非预期执行引发的思考

    问题出现 这天在写一个页面,想谨慎些就用了int.TryParse,结果出问题了. 代码如下: int id = 1000; //Request.QueryString["id"] ...

  2. centos 中GTK的安装

    centos 中GTK的安装 yum install gtk*

  3. [svc][op]杀进程

    杀进程: 杀服务名 /usr/bin/killall -HUP syslogd 杀掉进程号 /bin/kill -USR1 $(cat /var/run/nginx.pid 2>/dev/nul ...

  4. Outlets 和Referencing Outlets的区别

    转自:http://blog.sina.com.cn/s/blog_4431c7610100sypy.html 我的理解就是连接与被连接的关系吧 Outlets里面显示的是你的属性, 以及连接着的目标 ...

  5. Unix系统编程(三)通用的I/O

    UNIX  IO模型的显著特点之一是输出输出概念的通用性,这意味着,4个同样的系统调用open,read,write和close可以对所有类型的文件执行IO操作,包括终端之类的设备.因此仅用这些系统调 ...

  6. java.lang.NoSuchMethodError: org.apache.spark.util.ThreadUtils$.newDae

    -classpath "C:\Program Files\Java\jdk1.8.0_131\jre\lib\charsets.jar;C:\Program Files\Java\jdk1. ...

  7. php 扩展模块添加

    1. 新增安装扩展模块的位置 [root@node_22 ~]# ls /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/ op ...

  8. 02 Java图形化界面设计——中间容器(Jpanel)

    上一篇讲解了Jframe顶层容器,例子中生成了一个空的窗体,在实际编程过程中,一般很少将文本框.按钮等组件直接放在顶层容器中进行布局,大多数时候是通过布局管理器结合中间容器对组件进行布局设置. 1.  ...

  9. 【BZOJ】2982: combination(lucas定理+乘法逆元)

    http://www.lydsy.com/JudgeOnline/problem.php?id=2982 少加了特判n<m return 0就wa了QAQ lucas定理:C(n, m)%p=( ...

  10. 【BZOJ】1665: [Usaco2006 Open]The Climbing Wall 攀岩(spfa)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1665 这题只要注意到“所有的落脚点至少相距300”就可以大胆的暴力了. 对于每个点,我们枚举比他的x ...