Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:案列过了 wa 求大神指点

Posted by 878617210 at 2014-08-06 20:54:09 on Problem 2833
In Reply To:案列过了 wa 求大神指点 Posted by:878617210 at 2014-08-06 17:03:27
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator