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 水题的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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  ...

  4. 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 ...

  5. Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题

    B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. angularJs入门篇-hello world 开头

    AngularJS 采用了完全不同的解决方案,它创建实时视图模板代替视图,而不是将数据合并进模板之后更新DOM. 任何一个独立视图组件中的值都是 动态替换的.这个功能可以说是AngularJS中最重要 ...

  2. 20155224 2016-2017-2 《Java程序设计》第6周学习总结

    20155224 2016-2017-2 <Java程序设计>第6周学习总结 教材学习内容总结 Thread线程: 定义某线程后,要有 xxx.stard(); Thread.sleep( ...

  3. Docker学习笔记三 Dockerfile 指令 定制镜像

    本文地址:https://www.cnblogs.com/veinyin/p/10412079.html  镜像是分层存储的,每一层都是独立存在的,修改当前层并不会修改其依赖的上一层,删除某一层也只是 ...

  4. nmap - 网络扫描

    NMap,Network Mapper 最早是Linux下的网络扫描和嗅探工具包 网络链接扫描; nmap -PT 192.168.1.1-111 # 先ping在扫描主机开放端口 nmap -O 1 ...

  5. 总结---Python中的面向对象!

    面向对象这种编程的范式每个语言都是通用的,这里总结一下python的面向对象语法,主要包含以下几个方面! 1 基本语法 # 定义类 class Person(object): n = 10 # 类变量 ...

  6. OpenWRT开发之——对C++的支持(解决库依赖问题)【转】

    转自:https://my.oschina.net/hevakelcj/blog/411944 摘要: 本文尝试用C++来开发一个cpp-demo包 遇到打包库依赖的问题,分析打包过程并解决了这个问题 ...

  7. Linux的软中断处理实现 【转】

    转自:http://blog.chinaunix.net/uid-25909619-id-3070190.html 一.概念   首先我们要知道为什么中断需要下半部 .我们可以想象一下,如果没有下半部 ...

  8. 由time.tzname返回值引发的对str、bytes转换时编码问题实践

    Windows 10家庭中文版,Python 3.6.4, 下午复习了一下time模块,熟悉一下其中的各种时间格式的转换:时间戳浮点数.struct_tm.字符串,还算顺利. 可是,测试其中的time ...

  9. SqlServer中查看索引的使用情况

    --查看数据库索引的使用情况 select db_name(database_id) as N'TOPK_TO_DEV', --库名 object_name(a.object_id) as N'Top ...

  10. APP性能测试开始之旅

    你是不是也跟我一样在工作中存在着同样的问题,APP版本在上线后不断的会有市场人员或者用户反馈页面加载慢,进入页面loading很久(实际我们设置的加载超时是15秒,15秒内加载出内容则显示,15秒外未 ...