A8239 | Winning Strategy
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
One university has just found out about a sport programming contest called ACM ICPC v2.0. This contest doesn't differ much from the well-known ACM ICPC, for example, the participants are not allowed to take part in the finals more than two times. However, there is one notable difference: the teams in the contest should consist of exactly $n$ participants.
Having taken part in several ACM ICPC v2.0 finals and having not won any medals, the students and the university governors realized that it's high time they changed something about the preparation process. Specifically, as the first innovation it was decided to change the teams' formation process. Having spent considerable amount of time on studying the statistics of other universities' performance, they managed to receive some interesting information: the dependence between the probability of winning a medal and the number of team members that participated in the finals in the past. More formally, we know $n+1$ real numbers $p_{0}<=p_{1}<=...<=p_{n}$ , where $p_{i}$ is the probability of getting a medal on the finals if the team has $i$ participants of previous finals, and other $n-i$ participants arrived to the finals for the first time.
Despite such useful data, the university governors are unable to determine such team forming tactics that would provide the maximum probability of winning a medal at ACM ICPC v2.0 finals on average (we are supposed to want to provide such result to the far future and we are also supposed to have an endless supply of students). And how about you, can you offer such optimal tactic? At the first stage the university governors want to know the value of maximum average probability.
More formally, suppose that the university sends a team to the $k$ -th world finals. The team has $a_{k}$ participants of previous finals ( $0<=a_{k}<=n$ ). Since each person can participate in the finals no more than twice, the following condition must be true: . Your task is to choose sequence  so that the limit $Ψ$ exists and it's value is maximal:
As  is an infinite sequence, you should only print the maximum value of the $Ψ$ limit.
Having taken part in several ACM ICPC v2.0 finals and having not won any medals, the students and the university governors realized that it's high time they changed something about the preparation process. Specifically, as the first innovation it was decided to change the teams' formation process. Having spent considerable amount of time on studying the statistics of other universities' performance, they managed to receive some interesting information: the dependence between the probability of winning a medal and the number of team members that participated in the finals in the past. More formally, we know $n+1$ real numbers $p_{0}<=p_{1}<=...<=p_{n}$ , where $p_{i}$ is the probability of getting a medal on the finals if the team has $i$ participants of previous finals, and other $n-i$ participants arrived to the finals for the first time.
Despite such useful data, the university governors are unable to determine such team forming tactics that would provide the maximum probability of winning a medal at ACM ICPC v2.0 finals on average (we are supposed to want to provide such result to the far future and we are also supposed to have an endless supply of students). And how about you, can you offer such optimal tactic? At the first stage the university governors want to know the value of maximum average probability.
More formally, suppose that the university sends a team to the $k$ -th world finals. The team has $a_{k}$ participants of previous finals ( $0<=a_{k}<=n$ ). Since each person can participate in the finals no more than twice, the following condition must be true: . Your task is to choose sequence  so that the limit $Ψ$ exists and it's value is maximal:
As  is an infinite sequence, you should only print the maximum value of the $Ψ$ limit.
输入格式
The first line contains an integer $n$ ( $3<=n<=100$ ), $n$ is the number of team participants. The second line contains $n+1$ real numbers with no more than 6 digits after decimal point $p_{i}$ ( $0<=i<=n,0<=p_{i}<=1$ ) — the probability of that the team will win a medal if it contains $i$ participants who has already been on the finals. Also the condition $p_{i}<=p_{i+1}$ should be fulfilled for all $0<=i<=n-1$ .
输出格式
Print the only real number — the expected average number of medals won per year if the optimal strategy is used. The result may have absolute or relative error $10^{-6}$ .
输入输出样例
输入 #1
3 0.115590 0.384031 0.443128 0.562356
输出 #1
0.4286122500
输入 #2
3 1 1 1 1
输出 #2
0.9999999999
In the second test, no matter what participants the team contains, it is doomed to be successful.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted