CF493B Vasya and Wrestling

/*
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>
int a[200005]={0},b[200005]={0};

int main()
{
    int _,aa=0,bb=0,temp,flag=0,last=0;
    scanf("%d",&_);
    while(_--)
    {
        if(_==0)                                  //记录最后一个数据是first的还是second的。
        {
            scanf("%d",&temp);
            if(temp>0) {a[aa++]=temp;last=1;}
            else b[bb++]=temp;
        }
        else
        {
            scanf("%d",&temp);
            if(temp>0) a[aa++]=temp;
            else b[bb++]=temp;
        }

    }
    long long sum=0;                        // 防止统计sum的时候爆了int。
    for(int i=0;a[i]||b[i];i++)
    {
        sum=a[i]+b[i]+sum;                 //对a,b分别相加,正好b是负数。所以依次相加防止爆了long long。
    }
    if(sum>0) printf("first\n");
    if(sum<0) printf("second\n");
    if(sum==0)
    {
        int i;
        for(i=0;a[i]||b[i];i++)
        {
            if(a[i]!=-b[i]){flag=1;break;}              //  处理字典序。
        }
        if(a[i]>-b[i]&&flag) printf("first\n");
        if(a[i]<-b[i]&&flag) printf("second\n");
        if(!flag) {if(last) printf("first\n");else printf("second\n");}
    }
    return 0;
}
//开始RE在了test 20,然后检查一看没加return 0。。。。我很好奇为什么还过了19个测试数据。然后发现数组开小了。改了就AC了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值