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 <stdio.h> using namespace std; int main() { int a[15],b[15],x,y; int n1,n2,n; long long s; double d; while(scanf("%d %d %d",&n1,&n2,&n)!=EOF) { s=0; if(n1==0&&n2==0&&n==0) { return 0; } for(int i=0;i<n1+n2;i++) { scanf("%d",&a[i] ); } sort(a,a+n1+n2); int j; for(int i=0,j=0;i<n2;i++,j++) { b[j]=a[i]; } for(int i=0;i<n1;i++) { a[i]=a[n2+i]; } x=a[0]; y=b[n2-1]; for(int i=0;i<n-n1-n2;i++) { int c; scanf("%d",&c); if(c>x) { swap(c,x); a[0]=x; s+=c; sort(a,a+n1); x=a[0]; } else if(c<y) { swap(c,y); b[n2-1]=y; s+=c; sort(b,b+n2); y=b[n2-1]; } else { s+=c; } } d=(double)s/(n-n1-n2); printf("%.6lf\n",d); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator