English · Original
Chinese · Translation
Formal · Original
Makes solves problems on Decoforces and lots of other different online judges. Each problem is denoted by its difficulty — a positive integer number. Difficulties are measured the same across all the judges (the problem with difficulty _d_ on Decoforces is as hard as the problem with difficulty _d_ on any other judge).
Makes has chosen _n_ problems to solve on Decoforces with difficulties _a_1, _a_2, ..., _a__n_. He can solve these problems in arbitrary order. Though he can solve problem _i_ with difficulty _a__i_ only if he had already solved some problem with difficulty (no matter on what online judge was it).
_Before starting this chosen list of problems, Makes has already solved problems with maximum difficulty _k_._
With given conditions it's easy to see that Makes sometimes can't solve all the chosen problems, no matter what order he chooses. So he wants to solve some problems on other judges to finish solving problems from his list.
_For every positive integer _y_ there exist some problem with difficulty _y_ on at least one judge besides Decoforces._
Makes can solve problems on any judge at any time, it isn't necessary to do problems from the chosen list one right after another.
Makes doesn't have too much free time, so he asked you to calculate the minimum number of problems he should solve on other judges in order to solve all the chosen problems from Decoforces.
## Input
The first line contains two integer numbers _n_, _k_ (1 ≤ _n_ ≤ 103, 1 ≤ _k_ ≤ 109).
The second line contains _n_ space-separated integer numbers _a_1, _a_2, ..., _a__n_ (1 ≤ _a__i_ ≤ 109).
## Output
Print minimum number of problems Makes should solve on other judges in order to solve all chosen problems on Decoforces.
[samples]
## Note
In the first example Makes at first solves problems _1_ and _2_. Then in order to solve the problem with difficulty _9_, he should solve problem with difficulty no less than _5_. The only available are difficulties _5_ and _6_ on some other judge. Solving any of these will give Makes opportunity to solve problem _3_.
In the second example he can solve every problem right from the start.
Makes 在 Decoforces 和许多其他在线评测系统上解题。每个问题都以其难度标记——一个正整数。所有评测系统上的难度衡量标准一致(Decoforces 上难度为 #cf_span[d] 的问题与任何其他评测系统上难度为 #cf_span[d] 的问题难度相同)。
Makes 从 Decoforces 上选择了 #cf_span[n] 个问题来解决,其难度分别为 #cf_span[a1, a2, ..., an]。他可以按任意顺序解决这些问题。但只有当他之前已经解决过某个难度至少为 #cf_span[ai - 1] 的问题时(无论该问题来自哪个在线评测系统),他才能解决难度为 #cf_span[ai] 的问题。
_在开始解决这个选定的问题列表之前,Makes 已经解决了难度最大为 #cf_span[k] 的问题。_
根据给定条件,显然在某些情况下,无论选择何种顺序,Makes 都无法解决所有选定的问题。因此,他希望在其他评测系统上解决一些问题,以便完成 Decoforces 上的列表。
_对于每个正整数 #cf_span[y],至少存在一个其他评测系统上难度为 #cf_span[y] 的问题。_
Makes 可以在任何时间解决任何评测系统上的问题,不必连续解决 Decoforces 上选定的问题。
Makes 的空闲时间不多,因此他请你计算他为了完成 Decoforces 上所有选定问题,最少需要在其他评测系统上解决多少个问题。
第一行包含两个整数 #cf_span[n], #cf_span[k](#cf_span[1 ≤ n ≤ 103], #cf_span[1 ≤ k ≤ 109])。
第二行包含 #cf_span[n] 个用空格分隔的整数 #cf_span[a1, a2, ..., an](#cf_span[1 ≤ ai ≤ 109])。
请输出 Makes 为解决 Decoforces 上所有选定问题,最少需要在其他评测系统上解决的问题数量。
在第一个例子中,Makes 首先解决第 _1_ 和第 _2_ 个问题。然后,为了求解难度为 _9_ 的问题,他必须先解决一个难度至少为 _5_ 的问题。其他评测系统上仅存在难度为 _5_ 和 _6_ 的问题。解决其中任意一个,都会使 Makes 获得解决第 _3_ 个问题的资格。
在第二个例子中,他可以从一开始就解决所有问题。
## Input
第一行包含两个整数 #cf_span[n], #cf_span[k](#cf_span[1 ≤ n ≤ 103], #cf_span[1 ≤ k ≤ 109])。第二行包含 #cf_span[n] 个用空格分隔的整数 #cf_span[a1, a2, ..., an](#cf_span[1 ≤ ai ≤ 109])。
## Output
请输出 Makes 为解决 Decoforces 上所有选定问题,最少需要在其他评测系统上解决的问题数量。
[samples]
## Note
在第一个例子中,Makes 首先解决第 _1_ 和第 _2_ 个问题。然后,为了求解难度为 _9_ 的问题,他必须先解决一个难度至少为 _5_ 的问题。其他评测系统上仅存在难度为 _5_ 和 _6_ 的问题。解决其中任意一个,都会使 Makes 获得解决第 _3_ 个问题的资格。在第二个例子中,他可以从一开始就解决所有问题。
**Definitions**
Let $ n \in \mathbb{Z}^+ $ be the number of chosen problems on Decoforces.
Let $ k \in \mathbb{Z}^+ $ be the maximum difficulty of problems already solved by Makes before starting.
Let $ A = (a_1, a_2, \dots, a_n) $ be a sequence of positive integers representing the difficulties of the chosen problems.
**Constraints**
1. $ 1 \leq n \leq 10^3 $
2. $ 1 \leq k \leq 10^9 $
3. $ 1 \leq a_i \leq 10^9 $ for all $ i \in \{1, \dots, n\} $
**Objective**
Determine the minimum number of additional problems Makes must solve on other judges (each with any positive integer difficulty) such that there exists an order to solve all problems in $ A $, satisfying the condition:
> To solve a problem with difficulty $ a_i $, Makes must have previously solved at least one problem with difficulty $ \geq \left\lceil \frac{a_i}{2} \right\rceil $.
(Note: The condition “he can solve problem $ i $ with difficulty $ a_i $ only if he had already solved some problem with difficulty $ \geq \left\lceil \frac{a_i}{2} \right\rceil $” is inferred from the example: difficulty 9 requires prior solution of a problem with difficulty $ \geq 5 = \lceil 9/2 \rceil $.)
Let $ S \subseteq \mathbb{Z}^+ $ be the set of difficulties of problems Makes has solved (initially $ S = \{ d \in \mathbb{Z}^+ \mid d \leq k \} $).
For each $ a_i \in A $, if $ \max(S) < \left\lceil \frac{a_i}{2} \right\rceil $, then Makes must solve at least one additional problem with difficulty $ \geq \left\lceil \frac{a_i}{2} \right\rceil $ before solving $ a_i $.
After solving a problem (on any judge), its difficulty is added to $ S $, and $ \max(S) $ may increase.
Find the minimum number of problems to solve on other judges such that all $ a_i \in A $ can be solved in some order.
**Formal Objective**
Compute the minimum number of elements to add to the initial set $ S_0 = \{ d \in \mathbb{Z}^+ \mid d \leq k \} $, such that there exists a permutation $ \pi \in S_n $ for which, for all $ j = 1, \dots, n $:
$$
\max\left( S_0 \cup \{ a_{\pi(1)}, \dots, a_{\pi(j-1)} \} \cup \{ \text{added problems} \} \right) \geq \left\lceil \frac{a_{\pi(j)}}{2} \right\rceil
$$
Equivalently, sort $ A $ in increasing order, simulate the process greedily, and count how many times $ \max(S) < \left\lceil \frac{a_i}{2} \right\rceil $, requiring an additional problem to be solved on another judge.
API Response (JSON)
{
"problem": {
"name": "C. Multi-judge Solving",
"description": {
"content": "Makes solves problems on Decoforces and lots of other different online judges. Each problem is denoted by its difficulty — a positive integer number. Difficulties are measured the same across all the ",
"description_type": "Markdown"
},
"platform": "Codeforces",
"limit": {
"time_limit": 1000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "CF825C"
},
"statements": [
{
"statement_type": "Markdown",
"content": "Makes solves problems on Decoforces and lots of other different online judges. Each problem is denoted by its difficulty — a positive integer number. Difficulties are measured the same across all the ...",
"is_translate": false,
"language": "English"
},
{
"statement_type": "Markdown",
"content": "Makes 在 Decoforces 和许多其他在线评测系统上解题。每个问题都以其难度标记——一个正整数。所有评测系统上的难度衡量标准一致(Decoforces 上难度为 #cf_span[d] 的问题与任何其他评测系统上难度为 #cf_span[d] 的问题难度相同)。\n\nMakes 从 Decoforces 上选择了 #cf_span[n] 个问题来解决,其难度分别为 #cf_span[a1,...",
"is_translate": true,
"language": "Chinese"
},
{
"statement_type": "Markdown",
"content": "**Definitions** \nLet $ n \\in \\mathbb{Z}^+ $ be the number of chosen problems on Decoforces. \nLet $ k \\in \\mathbb{Z}^+ $ be the maximum difficulty of problems already solved by Makes before starting....",
"is_translate": false,
"language": "Formal"
}
]
}