{"problem":{"name":"B. Three-level Laser","description":{"content":"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 descript","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF924B"},"statements":[{"statement_type":"Markdown","content":"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.\n\nThree distinct states _i_, _j_ and _k_ are selected, where _i_ < _j_ < _k_. After that the following process happens:\n\n1.  initially the atom is in the state _i_,\n2.  we spend _E__k_ - _E__i_ energy to put the atom in the state _k_,\n3.  the atom emits a photon with useful energy _E__k_ - _E__j_ and changes its state to the state _j_,\n4.  the atom spontaneously changes its state to the state _i_, losing energy _E__j_ - _E__i_,\n5.  the process repeats from step 1.\n\nLet's define the energy conversion efficiency as , i. e. the ration between the useful energy of the photon and spent energy.\n\nDue to some limitations, Arkady can only choose such three states that _E__k_ - _E__i_ ≤ _U_.\n\nHelp Arkady to find such the maximum possible energy conversion efficiency within the above constraints.\n\n## Input\n\nThe 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_.\n\nThe 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\n## Output\n\nIf it is not possible to choose three states that satisfy all constraints, print _\\-1_.\n\nOtherwise, 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.\n\nFormally, let your answer be _a_, and the jury's answer be _b_. Your answer is considered correct if .\n\n[samples]\n\n## Note\n\nIn the first example choose states 1, 2 and 3, so that the energy conversion efficiency becomes equal to .\n\nIn the second example choose states 4, 5 and 9, so that the energy conversion efficiency becomes equal to .","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"元素 X 的一个原子可以处于 #cf_span[n] 个不同的能态，其能量为 #cf_span[E1 < E2 < ... < En]。Arkady 希望利用该元素构建一个激光器，采用三级方案。以下是该方案的简化描述：\n\n选择三个不同的能态 #cf_span[i], #cf_span[j] 和 #cf_span[k]，满足 #cf_span[i < j < k]。随后发生以下过程：\n\n定义能量转换效率为 ，即光子有用能量与消耗能量之比。\n\n由于某些限制，Arkady 只能选择满足 #cf_span[Ek - Ei ≤ U] 的三个能态。\n\n请帮助 Arkady 在上述约束下找到可能的最大能量转换效率。\n\n第一行包含两个整数 #cf_span[n] 和 #cf_span[U] (#cf_span[3 ≤ n ≤ 105], #cf_span[1 ≤ U ≤ 109]) —— 能态数量和 #cf_span[Ek] 与 #cf_span[Ei] 之间的最大允许差值。\n\n第二行包含一个整数序列 #cf_span[E1, E2, ..., En] (#cf_span[1 ≤ E1 < E2... < En ≤ 109])。保证所有 #cf_span[Ei] 按递增顺序给出。\n\n如果无法选择满足所有约束的三个能态，请输出 _-1_。\n\n否则，输出一个实数 #cf_span[η] —— 可能的最大能量转换效率。你的答案若绝对误差或相对误差不超过 #cf_span[10 - 9]，则被视为正确。\n\n形式上，设你的答案为 #cf_span[a]，标准答案为 #cf_span[b]，当  时你的答案被视为正确。\n\n在第一个示例中，选择能态 #cf_span[1], #cf_span[2] 和 #cf_span[3]，使能量转换效率变为 。\n\n在第二个示例中，选择能态 #cf_span[4], #cf_span[5] 和 #cf_span[9]，使能量转换效率变为 。\n\n## Input\n\n第一行包含两个整数 #cf_span[n] 和 #cf_span[U] (#cf_span[3 ≤ n ≤ 105], #cf_span[1 ≤ U ≤ 109]) —— 能态数量和 #cf_span[Ek] 与 #cf_span[Ei] 之间的最大允许差值。第二行包含一个整数序列 #cf_span[E1, E2, ..., En] (#cf_span[1 ≤ E1 < E2... < En ≤ 109])。保证所有 #cf_span[Ei] 按递增顺序给出。\n\n## Output\n\n如果无法选择满足所有约束的三个能态，请输出 _-1_。否则，输出一个实数 #cf_span[η] —— 可能的最大能量转换效率。你的答案若绝对误差或相对误差不超过 #cf_span[10 - 9]，则被视为正确。形式上，设你的答案为 #cf_span[a]，标准答案为 #cf_span[b]，当  时你的答案被视为正确。\n\n[samples]\n\n## Note\n\n在第一个示例中，选择能态 #cf_span[1], #cf_span[2] 和 #cf_span[3]，使能量转换效率变为 。在第二个示例中，选择能态 #cf_span[4], #cf_span[5] 和 #cf_span[9]，使能量转换效率变为 。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"Given:\n\n- $ n $: number of energy states, $ 3 \\leq n \\leq 10^5 $\n- $ U $: maximum allowed energy difference, $ 1 \\leq U \\leq 10^9 $\n- $ E_1 < E_2 < \\dots < E_n $: strictly increasing sequence of energy levels, $ 1 \\leq E_i \\leq 10^9 $\n\nDefine a valid triple $ (i, j, k) $ such that:\n- $ 1 \\leq i < j < k \\leq n $\n- $ E_k - E_i \\leq U $\n\nThe energy conversion efficiency for such a triple is defined as:\n$$\n\\eta = \\frac{E_k - E_j}{E_k - E_i}\n$$\n\nObjective:  \nMaximize $ \\eta $ over all valid triples $ (i, j, k) $ satisfying the constraints.\n\nIf no such triple exists, output $ -1 $.\n\n---\n\n**Formal Statement:**\n\nLet $ \\mathcal{T} = \\left\\{ (i, j, k) \\in \\mathbb{N}^3 \\mid 1 \\leq i < j < k \\leq n \\text{ and } E_k - E_i \\leq U \\right\\} $\n\nDefine:\n$$\n\\eta(i, j, k) = \\frac{E_k - E_j}{E_k - E_i}\n$$\n\nFind:\n$$\n\\max_{(i,j,k) \\in \\mathcal{T}} \\eta(i,j,k)\n$$\n\nIf $ \\mathcal{T} = \\emptyset $, output $ -1 $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF924B","tags":["binary search","greedy","two pointers"],"sample_group":[["4 4\n1 3 5 7","0.5"],["10 8\n10 13 15 16 17 19 20 22 24 25","0.875"],["3 1\n2 5 10","\\-1"]],"created_at":"2026-03-03 11:00:39"}}