标签:
Time Limit: 500/200 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 2460 Accepted Submission(s): 1184
///总共需要n*k分钟,所以m个医生总共需要n*k/m分钟 #include<iostream> #include<cstdio> #include<cstring> #include<math.h> #include<queue> using namespace std; double a[25]; int main() { int n; while(scanf("%d",&n)!=EOF,n){ double MIN = 99,MAX = -1; int t1 = 1,t2 = 1; for(int i=1;i<=n;i++){ scanf("%lf",&a[i]); if(a[i]>MAX){ t1 = i; MAX = a[i]; } if(a[i]<MIN){ t2 = i; MIN = a[i]; } } double sum = 0; for(int i=1;i<=n;i++){ if(i==t1||i==t2) continue; sum+=a[i]; } sum/=(n-2); MIN = 99; int res = 1; for(int i=1;i<=n;i++){ if(i==t1||i==t2) continue; a[i] = fabs(sum-a[i]); if(MIN>a[i]){ res = i; MIN = a[i]; } else if(MIN==a[i]&&i<res){ res = i; MIN = a[i]; } } printf("%d\n",res); } return 0; }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5616610.html