题本不难,只是要多重处理,另外注意数字和超出int范围。认真读题,好好学习英语~

<pre name="code" class="cpp">#include <iostream>
#include<cstdio>
#include<cmath>
#define LL long long
using namespace std;
const int maxn=2e5+1;
LL n,q1[maxn],q2[maxn],top1,top2,sum1,sum2;
int main(int argc, char *argv[]) {
//freopen("cin.txt","r",stdin);
while(cin>>n){
int i,t;
top1=top2=0;
sum1=sum2=0;
for(i=0;i<n;i++){
scanf("%d",&t);
if(t>0){
q1[top1++]=t;
sum1+=t;
}
else {
q2[top2++]=(-t);
sum2+=(-t);
}
}
if(sum1!=sum2){
if(sum1>sum2)printf("first\n");
else printf("second\n");
}
else {
bool judge=0;
for(i=0;i<min(top1,top2);i++){
if(q1[i]>q2[i]){
printf("first\n");
judge=1;
break;
}
else if(q1[i]<q2[i]){
printf("second\n");
judge=1;
break;
}
}
if(!judge){
if(top1>top2){
printf("first\n");
judge=1;
}
else if(top1<top2){
printf("second\n");
judge=1;
}
}
if(!judge){
if(t>0)printf("first\n"); //here t: the last technique
else printf("second\n");
}
}
}
return 0;
}