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. javascript 反调试 监听用户打开了Chrome devtool

    let div = document.createElement('div'); let loop = setInterval(() => {     console.log(div);     ...

  2. JAVA 数组格式的json字符串转换成List

    一. import org.codehaus.jackson.type.TypeReference; import org.codehaus.jackson.map.ObjectMapper; Obj ...

  3. python模块学习之warnings

    warnings.warn(message, category=None, stacklevel=, source=None) 发出警告,或者忽略它或引发异常. category参数(如果给定)必须是 ...

  4. linux根据进程号PID查找启动程序的全路径

    linux根据进程号PID查找启动程序的全路径 2014-01-25 11:09 18629人阅读 评论(0) 收藏 举报  分类: Linux系统管理(29)  版权声明:本文为博主原创文章,未经博 ...

  5. Oracle之标示符无效

    一.引言 今天使用Oracle客户端执行一条sql语句 order by colname3 结果一直提示标示符无效,以为是自己把列名写错了打开表的列,一个字母一个字母的比对,还是没有错 二.原因及解决 ...

  6. STM32F10x_硬件I2C读写EEPROM(标准外设库版本)

    Ⅰ.写在前面 上一篇文章是“STM32F10x_模拟I2C读写EEPROM”,讲述使用IO口模拟I2C总线通信,对EEPROM(AT24Xxx)进行读写操作的过程. 上一篇文章主要内容:I2C协议.模 ...

  7. 大数据(9) - Flume的安装与使用

    Flume简介 --(实时抽取数据的工具) 1) Flume提供一个分布式的,可靠的,对大数据量的日志进行高效收集.聚集.移动的服务,Flume只能在Unix环境下运行. 2) Flume基于流式架构 ...

  8. 关于selenium IDE找不到元素bug

    使用 selenium IDE 录制脚本,经常会发生 这样一种错误. 页面上,明明存在这个元素,就是找不到. 其实原理很简单   , 按钮 点击,没有时间延迟,但是页面加载,需要一段时间. 页面元素还 ...

  9. 那些让人睡不着觉的bug,你有没有遭遇过?

    我先讲一个小故事,以前在外企工作时的一个亲身经历. 当时我所在的team,负责手机上多媒体Library方面的开发.有一天,一个具有最高等级的bug被转到了我的手上.这个bug非常诡异,光是重现它就需 ...

  10. 【转】redis C接口hiredis 简单函数使用介绍

    from : http://blog.csdn.net/kingqizhou/article/details/8104693 hiredis是redis数据库的C接口,目前只能在linux下使用,几个 ...