B. Vasya and Wrestling
time limit per test 2 seconds
memory limit per test 256 megabytes
input standard input
output standard output

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 test(s)
input
5
1
2
-3
-4
3
output
second
input
3
-1
-2
3
output
first
input
2
4
-4
output
second
Note

Sequence x  =  x1x2... x|x| is lexicographically larger than sequence y  =  y1y2... y|y|, if either |x|  >  |y| and x1  =  y1,  x2  =  y2, ... ,  x|y|  =  y|y|, or there is such number r (r  <  |x|, r  <  |y|), that x1  =  y1,  x2  =  y2,  ... ,  xr  =  yr and xr  +  1  >  yr  +  1.

We use notation |a| to denote length of sequence a.

模拟

#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
ll i,j,t,n,m,l,r,k,z,y,x;
ll a[200005],b[200005];
ll suma,sumb;
int main()
{
scanf("%I64d",&n);
a[0]=b[0]=0;
suma=sumb=0;
for (i=1;i<=n;i++)
{
scanf("%I64d",&x);
if (x>0)
{
a[++a[0]]=x;
suma+=x;
}
if (x<0)
{
b[++b[0]]=-x;
sumb+=-x;
}
t=x;
}
if (suma>sumb) printf("first\n");
else if (suma<sumb) printf("second\n");
else
{
for (i=1;i<=max(a[0],b[0]);i++) if (a[i]!=b[i]) break;
if (a[i]>b[i]) printf("first\n");
else if (a[i]<b[i]) printf("second\n");
else
{
if (t>0) printf("first\n");
else printf("second\n");
}
}
return 0;
}

cf493B Vasya and Wrestling的更多相关文章

  1. Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题

    B. Vasya and Wrestling 题目连接: http://codeforces.com/contest/493/problem/B Description Vasya has becom ...

  2. CodeForces 493B Vasya and Wrestling 【模拟】

    B. Vasya and Wrestling time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  3. codeforces 493B.Vasya and Wrestling 解题报告

    题目链接:http://codeforces.com/problemset/problem/493/B 题目意思:给出 n 个 techniques,每个 technique 的值为 ai. ai & ...

  4. Codeforces Round #281 (Div. 2)

    题目链接:http://codeforces.com/contest/493 A. Vasya and Football Vasya has started watching football gam ...

  5. codeforces493B

    Vasya and Wrestling CodeForces - 493B Vasya has become interested in wrestling. In wrestling wrestle ...

  6. Codeforces Round #281 (Div. 2) B 模拟

    B. Vasya and Wrestling time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  7. Milliard Vasya's Function-Ural1353动态规划

    Time limit: 1.0 second Memory limit: 64 MB Vasya is the beginning mathematician. He decided to make ...

  8. CF460 A. Vasya and Socks

    A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  9. 递推DP URAL 1353 Milliard Vasya's Function

    题目传送门 /* 题意:1~1e9的数字里,各个位数数字相加和为s的个数 递推DP:dp[i][j] 表示i位数字,当前数字和为j的个数 状态转移方程:dp[i][j] += dp[i-1][j-k] ...

随机推荐

  1. delphi算法

    /  求余 mod 取模 var a1,a2,a3 : Integer; b1,b2,b3 : Integer; c1,c2 : Integer;begin a1 := 987; //ShowMess ...

  2. 白话C#:特性(转)

    不管怎么样,转过来再说. http://www.kuqin.com/dotnet/20080628/10196.html 系列文章索引:<白话C#> 首先要说的是,可能一些刚接触C#的朋友 ...

  3. React Native 初识

    Facebook 在 React.js Conf 2015 大会上推出了基于 JavaScript 的开源框架 React Native,本中文教程翻译自 React Native 官方文档. Rea ...

  4. cocoapods 的使用心得

    一般我们下载的demo里边含有cocoapods 我们需要 在终端上输入命令,让他能够成功运行 步骤如下: 打开终端  cd 项目目录  直接拖动到终端里边就可以, 然后 pod install 如果 ...

  5. android之字体阴影效果

    今天刚刚好做了个字体阴影的效果,感觉加上了阴影的效果立体感十足啊!写了个简单的demo与大家分享下!主要是以下四个属性 android:shadowColor  阴影的颜色  android:shad ...

  6. 冷门却使用的 javascript 技巧

    前端已经被玩儿坏了!像用近似乱码的 javascript 拼一个图形,并且能够正常执行等炫酷的玩意已经不是什么新闻了,像用||操作符给变量赋默认值也是人尽皆知的旧闻了,今天看到Quora上一个帖子,瞬 ...

  7. 减少iOS应用程序安装包大小

    安装包优化大小方法: <资源优化> 1.去除无用资源 通过几次项目的升级后,项目中会出现一些没有用到的图片.这些图片在我们导入到项目中后,之后项目升级过程后并没有再次用到. 那这些图片我们 ...

  8. JAVA内存区域和GC机制

    目录 Java垃圾回收概况 Java内存区域 Java对象的访问方式 Java内存分配机制 Java GC机制 垃圾收集器 Java垃圾回收概况 Java GC(Garbage Collection, ...

  9. js千分位转换

    var money = 1234567.55; var sMoney = money.toLocaleString(); console.info(sMoney); console.info(pars ...

  10. windows server 2003 AD

    本文转载:http://www.cnblogs.com/zfanlong1314/admin/EditPosts.aspx?opt=1 今天教大家用windows server2003系统建立Acti ...