CF924B.Three-level Laser
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
An atom of element X can exist in n distinct states with energies _E_1 < _E_2 < ... < E__n. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme.
Three distinct states i, j and k are selected, where i < j < k. After that the following process happens:
- initially the atom is in the state i,
- we spend E__k - E__i energy to put the atom in the state k,
- the atom emits a photon with useful energy E__k - E__j and changes its state to the state j,
- the atom spontaneously changes its state to the state i, losing energy E__j - E__i,
- the process repeats from step 1.
Let's define the energy conversion efficiency as
, i. e. the ration between the useful energy of the photon and spent energy.
Due to some limitations, Arkady can only choose such three states that E__k - E__i ≤ U.
Help Arkady to find such the maximum possible energy conversion efficiency within the above constraints.
元素 X 的一个原子可以处于 n 个不同的能态,其能量分别为 E1<E2<⋯<En。Arkady 希望利用该元素构建一台激光器,采用三能级方案。该方案的简化描述如下:
选取三个互异的能态 i、j 和 k,满足 i<j<k。随后发生如下过程:
- 原子初始处于能态 i;
- 我们消耗 Ek−Ei 的能量,将原子激发至能态 k;
- 原子发射一个具有有用能量 Ek−Ej 的光子,并跃迁至能态 j;
- 原子通过自发辐射跃迁回能态 i,释放能量 Ej−Ei;
- 过程从第 1 步起重复进行。
我们定义能量转换效率为
,
即:光子的有用能量与所消耗能量之比。
由于某些限制,Arkady 只能选择满足 Ek−Ei≤U 的三能态组合。
请帮助 Arkady 在上述约束条件下,找出可能达到的最大能量转换效率。
输入格式
The first line contains two integers n and U (3 ≤ n ≤ 105, 1 ≤ U ≤ 109) — the number of states and the maximum possible difference between E__k and E__i.
The second line contains a sequence of integers _E_1, _E_2, ..., E__n (1 ≤ _E_1 < _E_2... < E__n ≤ 109). It is guaranteed that all E__i are given in increasing order.
第一行包含两个整数 n 和 U(3≤n≤105,1≤U≤109)—— 分别表示状态的数量以及 Ek 与 Ei 之间可能的最大差值。
第二行包含一个整数序列 E1, E2, …, En(1≤E1<E2<⋯<En≤109)。保证所有 Ei 均以递增顺序给出。
输出格式
If it is not possible to choose three states that satisfy all constraints, print -1.
Otherwise, print one real number η — the maximum possible energy conversion efficiency. Your answer is considered correct its absolute or relative error does not exceed 10 - 9.
Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if
.
如果无法选择三个满足所有约束条件的状态,则输出 -1。
否则,输出一个实数 η —— 最大可能的能量转换效率。当你的答案的绝对误差或相对误差不超过 10−9 时,即视为正确。
形式化地,设你的答案为 a,评测组的答案为 b。若满足

则你的答案视为正确。
输入输出样例
输入#1
4 4 1 3 5 7
输出#1
0.5
输入#2
10 8 10 13 15 16 17 19 20 22 24 25
输出#2
0.875
输入#3
3 1 2 5 10
输出#3
-1
说明/提示
In the first example choose states 1, 2 and 3, so that the energy conversion efficiency becomes equal to
.
In the second example choose states 4, 5 and 9, so that the energy conversion efficiency becomes equal to
.
在第一个例子中,选择状态 1、2 和 3,使得能量转换效率等于
。
在第二个例子中,选择状态 4、5 和 9,使得能量转换效率等于
。
输入解题思路,AI测评打分。不知道怎么写?