Small Q Series of stories-the best referee problem Description the past 2012 to small q is a very sad reminder of a year, lovelorn 12 times, every time to be depressed 1 months.
Fortunately, little Q is a sports fan, in the most painful times, he often use to watch various sports programs to anesthesia himself, such as the London Olympics, small q often on the weekend invited a group of single colleagues gathered in their own dwelling, while drinking beer, while bragging.
Small Q Most like to see is diving, the main reason is because the project has the Chinese to participate, and Chinese players have a great chance of winning, generally will not add to their own plugging, or how to talk about physical therapy injury.
An important part of the diving project is the referee scoring, small Q they sometimes feel that a referee is unfair, is not intentionally in the pressure of Chinese players score. So every time a player dives, they are like the referee on the TV to score the players, and rules, who scores and final score closest to who is the best referee among them, on-site award beer a cup!
Among them, the final score is calculated as: N Individual score, remove a maximum score, remove a minimum score, then add the remaining points, divided by N-2 is the final score.
By virtue of "watching sports therapy injury" and trained professional sports knowledge, small Q almost every win, this night, small q is doomed to be drunk ... Input inputs contain multiple sets of test cases.
Each set of test cases is first an integer n, representing the number of referees, followed by n real numbers, indicating that the score of n pi,n is 0 o'clock end input.
[Technical specification]
5 <= N <= 20
0<=pi<=10 output please calculate and output the number of the best referee, each set of data output for one row, if there are more than the best referee, only the one with the lowest output number is required.
Special Note: The ref number starts from 1 in the order of scoring, and so on, and the last person is numbered n. Sample INPUT5 8.3 9.2 8.7 8.9 9.0
0 Sample Output4 Sample input water, remove the highest score lowest score to find the average score, and then each score (except the highest score minimum) and the average ratio, the closest output that ordinal.
#include <cstdio>#include<iostream>#include<string>#include<sstream>#include<cstring>#include<stack>#include<queue>#include<algorithm>#include<cmath>#include<map>#definePI ACOs (-1.0)#defineMS (a) memset (A,0,sizeof (a))#defineMSP Memset (Mp,0,sizeof (MP))#defineMSV memset (vis,0,sizeof (VIS))using namespacestd;//#define LOCALstructnode{intNo; DoubleFen;};intCMP (Node A,node b) {returna.fen<B.fen;}intMain () {#ifdef LOCAL freopen ("In.txt","R", stdin);#endif //LOCALIos::sync_with_stdio (false); Vector<Node>v; intN; Node T; while(cin>>n&&N) {v.clear (); for(intI=1; i<=n;i++) Cin>>t.fen,t.no=I,v.push_back (t); Sort (V.begin (), V.end (), CMP); Doublesum=0; for(intI=1; i<n-1; i++) sum+=V[i].fen; Sum/=n-2; Doubleminn=999; intMini=1; for(intI=1; i<n-1; i++) { if(ABS (V[i].fen-sum) <Minn) Minn=abs (v[i].fen-sum), mini=i; } printf ("%d\n", v[mini].no); } return 0;}
View Code
HDU 4520 Small Q Series-best referee (STL)