Distribution Money
Time limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 276 Accepted Submission (s): 163
Problem Descriptionafa want to distribution she money to somebody. She divide her money into n same parts. One who want to get the money can get more than one part. But if one man's money was more than the sum of all others '. He Shoule be punished. Each one of the get a part of the money would write down his ID on the that part.
Inputthere is multiply cases.
For each case,there are a single integer n (1<=n<=1000) on first line.
In second line,there was n integer a1,a2...an (0<=ai<10000) AI is the the-the-ith man ' s ID.
Outputoutput ID of the man should is punished.
If Nobody should be punished,output-1.
Sample Input31 1 242 1 4 3
Sample output1-1
Sourcebestcoder Round #50 (Div.2) water. When the game was stupid, two rounds, mom.
Break ... .
/************************************************************************* > File name:code/bc/#50/1001.cpp & Gt AUTHOR:111QQZ > Email: [email protected] > Created time:2015 August 08 Saturday 19:02 16 seconds ************************* ***********************************************/#include<iostream>#include<iomanip>#include<cstdio>#include<algorithm>#include<cmath>#include<cstring>#include<string>#include<map>#include<Set>#include<queue>#include<vector>#include<stack>#defineY0 ABC111QQZ#defineY1 HUST111QQZ#defineYn hez111qqz#defineJ1 CUTE111QQZ#defineTM CRAZY111QQZ#defineLR DYING111QQZusing namespacestd;#defineREP (i, n) for (int i=0;i<int (n); ++i)typedefLong Longll;typedef unsignedLong LongULL;Const intINF =0x7fffffff;intcnt[10005];intN;intx;intMain () { while(SCANF ("%d", &n)! =EOF) { BOOLFlag =false; memset (CNT,0,sizeof(CNT)); for(inti =0; I < n; i + +) {scanf ("%d",&x); CNT[X]++; if(flag)Continue; if(cnt[x]>n/2) {flag=true; cout<<x<<Endl; } } if(!flag) {cout<<-1<<Endl; } } return 0;}
Hdu 5364 (bc#50 1001) Distribution Money