Research Productivity Index

Research Productivity Index

 Kattis - researchproductivityindex 

Angela is a new PhD student and she is nervous about the upcoming paper submission deadline of this year’s research conference. She has been working on multiple projects throughout the past year. Luckily most of the projects concluded successfully, and she came up with nncandidate papers. However not all of the papers were born equal—some have better results than others. Her advisor believes she should only submit the papers with “good enough” results so they have a high chance of getting accepted.

Angela’s research group has a unique way of evaluating the success of paper submissions. They use the research productivity index, defined as aa/saa/s, where ss is the total number of papers submitted, and aa is the number of papers that are accepted by the conference. When a=0a=0, the index is defined to be zero. For example:

  • if one paper is submitted and it gets accepted, the index is 11/1=111/1=1;

  • if 44 papers are submitted and all get accepted, the index is 44/4=444/4=4;

  • if 1010 papers are submitted and 33 get accepted, the index is 33/10≈1.39038933/10≈1.390389;

  • if 55 papers are submitted and 44 get accepted, the index is 44/5≈3.03143344/5≈3.031433;

  • if 33 papers are submitted and all get rejected (a=0a=0), the index is 00.

Intuitively, to get a high research productivity index one wants to get as many papers accepted as possible while keeping the acceptance rate high.

For each of her nn papers, Angela knows exactly how likely it is that the conference would accept the paper. If she chooses wisely which papers to submit, what is the maximum expected value of her research productivity index?

Input

The first line of the input has a single integer nn (1≤n≤1001≤n≤100), the number of Angela’s candidate papers. The next line has nn space-separated integers giving the probability of each paper getting accepted. Each probability value is given as an integer percentage between 11 and 100100, inclusive.

Output

Output the maximum expected value of Angela’s research productivity index. Your answer is considered correct if it has an absolute or relative error of no more than 10−610−6.

Sample Input 1 Sample Output 1
5
30 50 70 60 90
2.220889579
Sample Input 2 Sample Output 2
6
30 90 30 90 30 90
2.599738456
Sample Input 3 Sample Output 3
4
10 10 10 10
0.368937005

 每次上交概率最大的1~n張試卷,求最大值

#include<bits/stdc++.h>
using namespace std;
double dp[120],a[120];

bool cmp(double numa,double numb)
{
    return numa>numb;
}
int main()
{
    int i,j,m,n,k,top,base;
    double ans,tmp;
    scanf("%d",&n);
    for(i = 1; i <= n; i++)
    {
        scanf("%lf",&a[i]);
        a[i]/=100;
    }
    sort(a+1,a+n+1,cmp);
    ans = 0;
    for(i = 1; i<=n; i++)
    {
        if(a[i]==1)

            base = i;
        else
            break;
    }
    for(k = 0; k< n; k++)
    {
        memset(dp,0,sizeof(dp));
        for(i = 0; i<= base; i++)
        {
            dp[base] = 1;

        }
        top = n-k;
        for(i = base+1; i <= top; i++)
        {
            dp[base]*=(1-a[i]);
        }
        for(i = base+1; i <= top; i++)//求二項分佈有k次實驗成功時的dp
        {
            for(j = i-1; j>=base; j--)
            {
                dp[j+1]+= dp[j]/(1-a[i])*a[i];
            }
        }

        tmp = 0;
        for(i = 1; i<= top; i++)
        {
            tmp += pow(i*1.0,i*1.0/(top*1.0))*dp[i];
        }
        ans = max(ans,tmp);
    }
    printf("%.9lf\n",ans);
    return 0;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章