B. Vasya and Wrestling

Source: Internet
Author: User

Ideas:

The main attention of this question is the judgment of dictionary order.

Pits: When the two teams score exactly the same as the sequence, who voted for the last goal who wins.

AC Code:

1#include <iostream>2#include <stdio.h>3#include <algorithm>4#include <cstring>5#include <string.h>6#include <math.h>7#include <queue>8#include <stack>9#include <stdlib.h>Ten#include <map> One using namespacestd; A #defineLL Long Long - #defineSF (a) scanf ("%d",& (a)); - #defineN 500050 the CharName1[n],name2[n]; - intF1[n],f2[n]; - intt1,t2; - intflag=0; + intdeal () { -     //Judge F1 and F2 dictionary order that big.  +     inta,b;a=b=0; A      while(A<t1 && b<T2) { at  -         if(F1[a] = =F2[b]) { -a++;b++; -             Continue; -         } -         Else if(F1[a]>f2[b])return 1; in         Else return 0; -  to     } +     if(T1==a && t2==b) { -         if(flag==1)return 1; the         Else return 0; *     } $     if(t2==b)return 1;//T2 First finished T1 long, its dictionary order is larger;Panax Notoginseng     return 0; - } the intMain () + { A     intN//t1=t2=0; theLL num1,num2;num1=num2=0; +scanf"%d",&n); -      while(n--){ $         intT; $scanf"%d",&t); -         if(t>0) { -NUM1 + =T; theflag=1; -f1[t1++] =T;Wuyi         } the         Else{ -Num2 + = (-t); Wuflag=2; -f2[t2++] = (-t); About         } $     } -     if(num1>num2) printf ("first\n"); -     Else if(num1<num2) printf ("second\n"); -     Else{ A         if(Deal ()) printf ("first\n"); +         Elseprintf"second\n"); the     } -     return 0; $}

B. Vasya and Wrestling

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.