CodeForces 157A Game Outcome
2 seconds
256 megabytes
standard input
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.
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.
Print the single number — the number of the winning squares.
1
1
0
2
1 2
3 4
2
4
5 7 8 4
9 5 3 2
1 6 6 4
9 5 7 3
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的更多相关文章
- CodeForces 451C Predict Outcome of the Game
Predict Outcome of the Game Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d &a ...
- codeforces 258div2C Predict Outcome of the Game
题目链接:http://codeforces.com/contest/451/problem/C 解题报告:三个球队之间一共有n场比赛,现在已经进行了k场,不知道每个球队的胜场是多少,如三个球队的胜场 ...
- codeforces 451C. Predict Outcome of the Game 解题报告
题目链接:http://codeforces.com/problemset/problem/451/C 题目意思:有3支球队(假设编号为1.2.3),总共要打 n 场比赛,已知已经错过这n场比赛中的 ...
- OUC_Summer Training_ DIV2_#5
这是做的最好的一次了一共做了4道题 嘻嘻~ A - Game Outcome Time Limit:2000MS Memory Limit:262144KB 64bit IO For ...
- 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 ...
- 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三队赢的场次的关系 ...
- CF451C Predict Outcome of the Game 水题
Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...
- 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 ...
- [codeforces 293]A. Weird Game
[codeforces 293]A. Weird Game 试题描述 Yaroslav, Andrey and Roman can play cubes for hours and hours. Bu ...
随机推荐
- node.js express安装问题
Windows下安装npm和express 1.如果不能在线安装,可以下载npm的zip解压到本地,然后把下面的bin目录加入到path中. 2.搞定npm后,执行了npm install expre ...
- 转: RabbitMQ实现中AMQP与MQTT消息收发异同
转自:http://www.cnblogs.com/lucifer1997/p/9438186.html 实现了AMQP与MQTT(至多一次)后,用多个队列以topic exchange的方式用相同交 ...
- Unity3D-rigidBody.velocity
还有半小时就下班了.写一下今天遇到的问题.处理方法以及一些自己的理解.理解的不一定对,还希望大家指正. 今天我做的效果是,hero的移动. 曾经做过用的是transform.Translate(Vec ...
- 特征组合&特征交叉
https://segmentfault.com/a/1190000014799038 https://www.jianshu.com/p/fc96675b6f8e https://blog.csdn ...
- unity5, UGUI刺穿问题解法
我希望在touch屏幕时player起跳,于是在playerControl.cs的Update函数中添加如下touch代码: if (Input.GetMouseButtonDown (0)) {/ ...
- 怎样优化UITableView的性能
在iOS App中,UITableView应该是使用率最高的.同一时候也是最为复杂的视图. 差点儿全部自带的应用中都能看到它的身影,可见它的重要性. 在使用UITableView时,会常常遇到性能上的 ...
- https证书最佳实战目录
[svc]openssl对称加密,非对称加密最佳实战 http://blog.csdn.net/iiiiher/article/details/78593464 [svc]证书的生成和各个字段的含义 ...
- (2.0)Smali系列学习之Smali语法
一.smali的包中信息 .class public Lcom/aaaaa;.super Lcom/bbbbb;.source "ccccc.java" 1.它是com.aaa ...
- MVC & Entity Framework(1)- 开发环境
一直都有接触asp.net mvc,希望自己借此次机会把Blog搭起来的同时能够更深入地学习相关知识. ①新建 打开VS2012,新建ASP.Net MVC 4项目,接着选择“空”模板(因为不想用自带 ...
- redis源码学习_整数集合
redis里面的整数集合保存的都是整数,有int_16.int_32和int_64这3种类型,和C++中的set容器差不多. 同时具备如下特点: 1.set里面的数不重复,均为唯一. 2.set里面的 ...