Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
案列过了 wa 求大神指点#include <iostream> #include <algorithm> #include <cstdio> using namespace std; bool cmp(int a,int b) { return a>b; } int main() { int a[25]; int n1,n2,n,f,p; long long s; while(scanf("%d%d%d",&n1,&n2,&n)==3&&n1&&n2&&n) { for(int i=0;i<n1+n2;i++) scanf("%d",&a[i]); sort(a,a+n1+n2,cmp); s=0; for(int i=n1+n2;i<n;i++) { scanf("%d",&f); if(f<=a[n1-1]&&f>=a[n1]) s+=f; else if(f>a[n1-1]) { s+=a[n1-1]; p=n1-1; while(f>a[p]&&f>a[p-1]&&p>0) { a[p]=a[p-1]; p--; } if(f>a[0]) a[0]=f; else a[p]=f; } else if(f<a[n1]) { s+=a[n1]; p=n1; while(f<a[p]&&f<a[p-1]&&p<n1+n2-1) { a[p]=a[p+1]; p++; } if(f>a[n1+n2-1]) a[n1+n2-1]=f; else a[p]=f; } } printf("%.6lf\n",(s*1.0)/((n-n1-n2)*1.0)); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator