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

B. Vasya and Wrestling

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

512-3-43

output

second

Note

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

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

 题意:两个人进行比赛, 给你n轮的分数,正数为first的,负数为second的分数,问你最后谁赢,分数多的赢,如果分数相同按照字典序大小比较,如果字典序也相同,按照谁最后一轮谁得分谁赢

题解:没什么好说的,看清题意就是了

///meek
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define pb push_back
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<‘0‘||ch>‘9‘){
        if(ch==‘-‘)f=-1;ch=getchar();
    }
    while(ch>=‘0‘&&ch<=‘9‘){
        x=x*10+ch-‘0‘;ch=getchar();
    }return x*f;
}
//****************************************
const int N=200005;
#define mod 10000007
#define inf 10000007
#define maxn 10000
int f[200005],s[N],k=0,kk=0;
int main() {
   ll ans=0,a;
    ll n=read();
    for(int i=1;i<=n;i++) {
        scanf("%I64d",&a);
        ans+=a;
        if(a>0) {
            f[++k]=a;
        }
        else s[++kk]=-a;
    }
    if(ans>0) {
        cout<<"first"<<endl;
    }
    else if(ans<0)cout<<"second"<<endl;
    else {
       for(int i=1;i<=min(kk,k);i++) {
        if(f[i]>s[i]) { cout<<"first"<<endl;return 0;}
        else if(f[i]<s[i]) {cout<<"second"<<endl;return 0;}
       }
      if(kk>k) {
          cout<<"second"<<endl;return 0;
       }
       else if(kk<k) {cout<<"first"<<endl;return 0;}
       if(a>0) {
          cout<<"first"<<endl;
    }
       else cout<<"second"<<endl;
    }
    return 0;
}

代码

时间: 2024-08-17 19:15:06

Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题的相关文章

Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力

A. Vasya and Football Vasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and for some fouls they receive red cards. A player who receives the second yellow card automatically receives a red

Codeforces Round #281 (Div. 2) C. Vasya and Basketball 排序

C. Vasya and Basketball Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from does

Codeforces Round #281 (Div. 2) D. Vasya and Chess 博弈

D. Vasya and Chess Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess. The queen is the piece that captures all squares on its vertical, horizontal and diagonal lines. If the cell is

Codeforces Round #281 (Div. 2) A. Vasya and Football(模拟)

简单题,却犯了两个错误导致WA了多次. 第一是程序容错性不好,没有考虑到输入数据中可能给实际已经罚下场的人再来牌,这种情况在system测试数据里是有的... 二是chronologically这个词没注意,其实如果输入是按时间顺序的,就直接在线处理就行了,用不着int team1[110][110],team2[110][110]两个数组. #include<iostream> #include<cstdio> #include<cstdlib> #include&l

Codeforces Round #337 (Div. 2) B. Vika and Squares 水题

B. Vika and Squares Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i. Vika also has an infinitely long rectangular piece of paper of width 1, consisting of s

Codeforces Round #632 (Div. 2) A. Little Artem(水题)

Young boy Artem tries to paint a picture, and he asks his mother Medina to help him. Medina is very busy, that's why she asked for your help. Artem wants to paint an n×mn×m board. Each cell of the board should be colored in white or black. Lets BB be

Codeforces Round #262 (Div. 2)460A. Vasya and Socks(简单数学题)

题目链接:http://codeforces.com/contest/460/problem/A A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya has n pairs of socks. In the morning of each day Vasya has to put o

Codeforces Round #319 (Div. 2) C Vasya and Petya&#39;s Game

因为所有整数都能被唯一分解,p1^a1*p2^a2*...*pi^ai,而一次询问的数可以分解为p1^a1k*p2^a2k*...*pi^aik,这次询问会把所有a1>=a1k && a2 >= a2k &&... a3 >= a3k的数从原来的集合中分开.ai表示pi的幂. 那么只有当这个数的素因子的最大幂都被询问过一次,这个数才能确定.因此答案是所有的不大于n的只有一个素因子的数. #include<bits/stdc++.h> using

Codeforces Round #281 (Div. 2) a

/**  * @brief Codeforces Round #281 (Div. 2) a  * @file a.cpp  * @author 面码  * @created 2014/12/04 17:49  * @edited  2014/12/04 17:58  * @type  implementation  *  */ #include <iostream> #include <fstream> #include <cstdlib> #include <