HDU 4520
看不起我?哼,迟早让你后悔,让你妒忌。操操操操。。。。。T_T
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #define LL __int64 using namespace std; const int N=25; struct Judger{ double score; int num; bool operator <(const Judger &a)const { if(score<a.score) return true; return false; } }p[N]; int n; int main(){ while(scanf("%d",&n),n){ for(int i=0;i<n;i++){ scanf("%lf",&p[i].score); p[i].num=1+i; } sort(p,p+n); double sum=0; for(int i=1;i<n-1;i++) sum+=p[i].score; double px=sum/(n-2); int ans=0; for(int i=1;i<n;i++){ if(fabs(p[i].score-px)<fabs(p[ans].score-px)){ ans=i; } else if(fabs(p[i].score-px)==fabs(p[ans].score-px)){ if(p[ans].num>p[i].num) ans=i; } } printf("%d\n",p[ans].num); } return 0; }