Research Productivity Index-概率dp

简介: 题意是:给出n份论文,每一分论文都有被接受以及被打回的可能性,输入有n个数,表示每一份被接受可能性的百分比,数据在1-100之间可以想到,我们用数组记录概率,然后再状态转移的过程中记录最大dp[i][j]代表前[i]个论文中,通过[j]篇论文的概率,贪心的考虑一下的话,我们要将接受概率大的放到前面,接受概率小的放到后面,这样能够保证一定的正确性,当然是先提交被接受概率大的呀然后一定是j <= i的在转移的过程中,dp[i][j] == dp[i-1][j] * P当前论文不通过 + dp[i-1][j-1] * P当前论文通过

题目描述


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 nn candidate 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.

微信图片_20220609153816.jpg


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?

输入描述:


The first line of the input has a single integer (1≤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 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-6


示例1


输入

复制

5
30 50 70 60 90

输出

复制

2.220889579


示例2


输入

复制

6
30 90 30 90 30 90


输出

复制

2.599738456


示例3


输入

复制

4
10 10 10 10


输出

复制

0.368937005


题意是:


给出n份论文,每一分论文都有被接受以及被打回的可能性,输入有n个数,表示每一份被接受可能性的百分比,数据在1-100之间


可以想到,我们用数组记录概率,然后再状态转移的过程中记录最大

dp[i][j]代表前[i]个论文中,通过[j]篇论文的概率,贪心的考虑一下的话,我们要将接受概率大的放到前面,接受概率小的放到后面,这样能够保证一定的正确性,当然是先提交被接受概率大的呀


然后一定是j <= i的

在转移的过程中,dp[i][j] == dp[i-1][j] * P当前论文不通过 + dp[i-1][j-1] * P当前论文通过 (一开始没有考虑不通过的那部分,直接gg)在处理的时候要注意一下边界问题,在这个问题中有一个dp[0][0]要初始化为1.0,这样在传递的过程中可以保证正确性(1.0 × 任何数不影响结果)


然后除了角落dp[0][0]之外,还有dp[i][0]没有处理,每一个dp[i][0]都可以通过前面的dp[i-1][0]转移过去,转移的方程就是:

dp[i][0] == dp[i-1][0] * P当前论文不通过


注意输入的是1–100,在处理的过程中要将这个数 × 0.01 or / 100来进行处理


int n;
double a[107];
double dp[107][107];
bool cmp(double a, double b)
{
    return a > b;
}
int main()
{
    cin >> n;
    double ans = 0;
    for(int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + 1 + n, cmp);
    dp[0][0] = 1.0;
    for(int i = 1; i <= n; i++)
    {
        dp[i][0] = dp[i - 1][0] * (100 - a[i]) * 0.01;
    }
    for(int i = 1; i <= n; i++)
    {
        double sum = 0;
        for(int j = 1; j <= i; j++)
        {
            dp[i][j] = dp[i - 1][j] * (100 - a[i]) * 0.01 + dp[i - 1][j - 1] * a[i] * 0.01;
            sum += dp[i][j] * pow(j, 1.0 * j / (1.0 * i));
        }
        ans = max(ans, sum);
    }
    printf("%.10lf\n", ans);
    return 0;
}


文章知识点与官方知识档案匹配,可进一步学习相关知识

算法技能树leetcode-动态规划22-括号生成7775 人正在系统学习中


目录
相关文章
|
机器学习/深度学习 数据采集 存储
Doc2EDAG: An End-to-End Document-level Framework for Chinese Financial Event Extraction论文解读
大多数现有的事件抽取(EE)方法只提取句子范围内的事件论元。然而,此类句子级事件抽取方法难以处理来自新兴应用程序(如金融、立法、卫生等)的大量文件
135 0
|
自然语言处理 数据挖掘 Java
Title2Event: Benchmarking Open Event Extraction with a Large-scale Chinese Title Dataset 论文解读
事件抽取(EE)对于新聚合和事件知识图构建等下游任务至关重要。大多数现有的EE数据集手动定义固定的事件类型,并为每种事件设计特定的模式
175 0
《40 Must Know Questions to test a data scientist on Dimensionality Reduction techniques》电子版地址
40 Must Know Questions to test a data scientist on Dimensionality Reduction techniques
104 0
《40 Must Know Questions to test a data scientist on Dimensionality Reduction techniques》电子版地址
《J.P.Morgan's massive guide to machine learning and big data jobs in finance》电子版地址
J.P.Morgan's massive guide to machine learning and big data jobs in finance
118 0
《J.P.Morgan's massive guide to machine learning and big data jobs in finance》电子版地址
|
Java
HDU - 2018 Multi-University Training Contest 3 - 1012: Visual Cube
HDU - 2018 Multi-University Training Contest 3 - 1012: Visual Cube
142 0
HDU - 2018 Multi-University Training Contest 3 - 1012: Visual Cube
|
人工智能 数据库 索引
2020 SIGMOD:BinDex A Two-Layered Index for Fast and Robust Scan 笔记
目前的查询扫描主要归类为两种方法,一种是顺序扫描 如全表扫描,一种是通过索引扫描 如b-tree等。1. 顺序扫描可能需要访问大量的无用的数据,特别是当选择率低的时候。2. 索引扫描在选择率较高的时候,可能会导致大量的随机内存访问。这些都会导致性能的下降,所以在执行查询操作时,需要根据具体的查询情况(如选择率的高低),选择合适的方法(选择顺序扫描,还是索引扫描)用于查询。但随着数据库查询负载变得复杂,很难去选择合适的方法应对特定的查询(到底是选顺序扫描?还是索引扫描?)。 因此本文提出了一种新的索引方案—BinDex(后面简称BD),可在不同的选择率情况下,同样能够快速地进行查询。 BinDe
|
人工智能
Practical Skill Test——AT
题目描述 We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is Ai,j.
121 0
Data Structures and Algorithms (English) - 6-8 Percolate Up and Down(20 分)
Data Structures and Algorithms (English) - 6-8 Percolate Up and Down(20 分)
112 0
Data Structures and Algorithms (English) - 6-15 Iterative Mergesort(25 分)
Data Structures and Algorithms (English) - 6-15 Iterative Mergesort(25 分)
200 0
Data Structures and Algorithms (English) - 6-13 Topological Sort(25 分)
Data Structures and Algorithms (English) - 6-13 Topological Sort(25 分)
117 0