B. Vasya and Wrestling
Vasya have become interested in wrestling. In wrestling wrestlers with techniques for which they is awarded points by judges. The wrestler who gets the most points wins.
When the numbers of points of both wrestlers was equal, the wrestler whose sequence of points is lexicographically GRE Ater, 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 has used (1≤ n ≤2 105).
The following n lines contain integer numbers a i (| A i |≤109, a i ≠0). If a i is positive, that's means that First wrestler performed the technique that is awarded With a i points. and If a i is negative, that means that The second wrestler performed the technique that is awarded With (- a i ) points.
The techniques is 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
Note
Sequencex=x1x2 ...x|x| Islexicographically larger than sequencey=y1y2 ...y|y|, if either|x| > |y| andx1 =y1, x 2 = y 2, ..., Em>x | Y | = y | Y |, or there is such number R ( R < | x |, r < | Y |), That x 1 = y 1, x 2 = y 2, ..., x r = y R and x R + 1 > y R + 1.
We Use notation | A| To denote length of sequence a.
Test Instructions : Two people to play, give you N-round score, positive number for first, negative for second score, ask you who wins, score more win, if the score is the same according to the dictionary order size comparison, if the dictionary order is the same, according to who the last round who scored who won
The puzzle: Nothing to say, see test instructions.
///Meek#include <bits/stdc++.h>using namespaceStd;typedefLong Longll;#defineMem (a) memset (A,0,sizeof (a))#definePB Push_backinline ll read () {ll x=0, f=1;CharCh=GetChar (); while(ch<'0'|| Ch>'9'){ if(ch=='-') f=-1; ch=GetChar (); } while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar (); }returnx*F;}//****************************************Const intn=200005;#defineMoD 10000007#defineINF 10000007#defineMAXN 10000intf[200005],s[n],k=0, kk=0;intMain () {ll ans=0, A; ll N=read (); for(intI=1; i<=n;i++) {scanf ("%i64d",&a); Ans+=A; if(a>0) {f[++k]=A; } Elses[++kk]=-A; } if(ans>0) {cout<<" First"<<Endl; } Else if(ans<0) cout<<"Second"<<Endl; Else { for(intI=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; } Elsecout<<"Second"<<Endl; } return 0;}
Code
Codeforces Round #281 (Div. 2) B. Vasya and Wrestling water questions