2199. [HZOI 2016] event vote, 2199 hzoi

Source: Internet
Author: User

2199. [HZOI 2016] event vote, 2199 hzoi

★★Input file:hztp.inOutput file:hztp.outSimple comparison
Time Limit: 0.5 s memory limit: 2 MB

[Description]

There are many and many people in the China-based shopping festival. n students are voting for one event. Now, more than half of the contestant's votes are received and their contestant numbers are requested (random contestant numbers)

[Input format]

The first line is an integer n.

The n integer Ni in the second row represents the contestant ID for the I student.

[Output format]

Number of more than half of contestants

[Example input]

10

5 1 2 5 5 2 3 5 5

[Sample output]

5

Tip]

In 100% of the data: n ≤ 300rmb, 1 ≤ Ni ≤ 300000000;

[Source]

Hzoid 2016

If the values are the same, the values are added. If the values are different, the values are subtracted.

 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<map> 5 using namespace std; 6 int n; 7 int maxn; 8 int num=1; 9 int p;10 int main()11 {12     13     freopen("hztp.in","r",stdin);14     freopen("hztp.out","w",stdout);15     //ios::sync_with_stdio(false);16     //scanf("%d",&n);17     scanf("%d",&n);18     for(int i=1;i<=n;i++)19     {20         scanf("%d",&p);21         if(p!=maxn)22         {23             num--;24             if(num<0)25             {26                 maxn=p;27                 num=1;28             }29         }30         else 31         num++;32     }33     cout<<maxn;34     return 0;35 }

 

Related Article

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.