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 ...
随机推荐
- Mysql select id 加上order by 后结果不一致
测试数据将近280万 1.SELECT id FROM cbbd ORDER BY id LIMIT 900000,10 2.SELECT id FROM cbbd LIMIT 900000,10 ...
- 从简单类型到复杂类型的参数传递用例,以及传递简单string类型的解决办法
一,简单类型的传值 比如 public Users Get(int id) ,它可以使用两种方式获取: api/default/5 $.get("/api/default" ...
- iOS必学技-cocoapods
我就不再造轮子了,网上的教程很详细,楼主亲测,好用. http://code4app.com/article/cocoapods-install-usage 楼主安装使用过程中遇到以下几个问题,同学们 ...
- Docker01 CentOS配置Docker
Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化.容器是完全使用沙箱机制,相互之间不会有任何 ...
- Mysql导入脚本失败,提示需要SUPER权限
1.删除: /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ 2.查看增删函数有没有重复 3.删除: set GLOBAL log ...
- mysql学习------二进制日志管理
MySQL二进制日志(Binary Log) a.它包含的内容及作用如下: 包含了所有更新了数据或者已经潜在更新了数据(比如没有匹配任何行的一个DELETE) 包含关于每个更新数据库( ...
- 公司软raid问题
RAID的技术介绍: stripe width(条带宽度):RAID中的磁盘数,就是组成这个stripe的磁盘数.如,4个磁盘组成的RAID 0,条带宽度就是4. stripe depth(条带深度) ...
- JavaScript如何获得input元素value值
转载地址:http://aquarius-zf.iteye.com/blog/605144 在页面中我们最常见的页面元素就是input了,但是我们如何用JavaScript得到网页input中输入的v ...
- 【Unity_UWP】Unity 工程发布win10 UWP 时的本地文件读取 (上篇)
Universal Windows Platform(UWP)是微软Windows10专用的通用应用平台,其目的在于在统一操作系统下控制所有智能电子设备. 自从Unity 5.2之后,配合VS 201 ...
- java注解方式解析xml格式
注解类和字段方式: @XStreamAlias("message") 别名注解 注解集合: @XStreamImplicit(itemFieldName="part&qu ...