Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题
B. Vasya and Wrestling
题目连接:
http://codeforces.com/contest/493/problem/B
Description
Vasya has become interested in wrestling. In wrestling wrestlers use techniques for which they are awarded points by judges. The wrestler who gets the most points wins.
When the numbers of points of both wrestlers are equal, the wrestler whose sequence of points is lexicographically greater, wins.
If the sequences of the awarded points coincide, the wrestler who performed the last technique wins. Your task is to determine which wrestler won.
Input
The first line contains number n — the number of techniques that the wrestlers have used (1 ≤ n ≤ 2·105).
The following n lines contain integer numbers ai (|ai| ≤ 109, ai ≠ 0). If ai is positive, that means that the first wrestler performed the technique that was awarded with ai points. And if ai is negative, that means that the second wrestler performed the technique that was awarded with ( - ai) points.
The techniques are given in chronological order.
Output
If the first wrestler wins, print string "first", otherwise print "second"
Sample Input
5
1
2
-3
-4
3
Sample Output
second
Hint
题意
有n个分数,然后输入,如果是正数,那么就属于第一个人,如果是负数,那么就属于第二个人。
谁分数大,谁胜利。
如果分数一样,那么看字典序大小。
如果字典序大小一样,看最后的那个数属于谁
题解:
读题比做题难……
模拟一下就好了
代码
#include<bits/stdc++.h>
using namespace std;
vector<int> a,b;
int judge()
{
for(int i=0;i<a.size()&&i<b.size();i++)
{
if(a[i]>b[i])return 1;
if(b[i]>a[i])return 2;
}
return 0;
}
int main()
{
int n;
long long sum1=0,sum2=0;
scanf("%d",&n);
int flag = 0;
for(int i=0;i<n;i++)
{
int x;scanf("%d",&x);
if(x>0)
{
a.push_back(x);
sum1+=x;
flag = 1;
}
else
{
b.push_back(-x);
sum2+=-x;
flag = 2;
}
}
if(sum1>sum2)return puts("first"),0;
if(sum2>sum1)return puts("second"),0;
if(judge()==1)return puts("first"),0;
else if(judge()==2)return puts("second"),0;
if(flag==1)return puts("first"),0;
else return puts("second"),0;
}
Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题的更多相关文章
- Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题
A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Codeforces Round #281 (Div. 2) D. Vasya and Chess 水
D. Vasya and Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #290 (Div. 2) A. Fox And Snake 水题
A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...
- Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题
B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos 水题
A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...
- Codeforces Round #359 (Div. 2) A. Free Ice Cream 水题
A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...
- Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题
A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分
C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
随机推荐
- bzoj千题计划234:bzoj3802: Vocabulary
http://www.lydsy.com/JudgeOnline/problem.php?id=3802 dp[i][0/1/2/3] 表示前i个字母,第1.2个字符串,第2.3个字符串的关系分别为 ...
- Linux命令(三)远程登录
- Linux - 用户操作
常用命令 users # 显示所有的登录用户 groups # 列出当前用户和他所属的组 who -q # 显示所有的登录用户 groupadd # 添加组 useradd user # 建立用户 p ...
- Linux笔记之如何分割文件或管道流:split
一.简介 在Linux中合并文件可以使用cat命令,后面跟上要合并的文件然后重定向到一个新的文件中即可,甚至可以追加合并.但如果要将一个大文件分割为多个小文件应该如何操作呢? 在Linux的coreu ...
- caoha
- Petrozavodsk WinterTraining 2015
PetrozavodskWinterTraining2015 A - Three Servers 题目描述:有\(n\)个数,将这\(n\)个数分成\(3\)堆,使得\(3\)堆中和的最大值减最小值最 ...
- poj2709
模拟题,在合成灰色的时候,每次取当前剩余最多的三种颜色,各取1mL合成.然后重新看剩余最多的是哪三个. #include <cstdio> #include <cstdlib> ...
- sysbench安装及性能测试
现在的压力测试工具各种各样,只要上手好几款功能强大点的而且比较大众化的压力测试工具即可,以下跟大家交流下sysbench的安装和压力测试 sysbench支持以下几种测试模式: 1.CPU运算性能 2 ...
- Oracle数据库创建表空间
//创建表空间create tablespace ACQUISITION_DATA datafile 'F:\app\kelly\oradata\acquisition\acquisition_dat ...
- IntelliJ IDEA快捷键:Esc
the Esc key in any tool window moves the focus to the editor. 任何工具窗口都会将焦点移动到编辑器.