101925: [AtCoder]ABC192 F - Potion

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $600$ points

Problem Statement

There are $N$ kinds of materials. Material $i$ has a magic power of $A_i$.

Takahashi, the magician, wants to make a potion by choosing one or more kinds from these materials and mixing them.

At the moment when he makes a potion by mixing $k$ kinds of materials, the magic power of the potion is the sum of the materials used. Then, every second, its magic power increases by $k$. Note that the increase of the magic power is a discrete - not continuous - process.

Takahashi will mix materials just once, at time $0$. What is the earliest time he can get a potion with a magic power of exactly $X$?

Under the constraints, it can be proved that it is possible to make a potion with a magic power of exactly $X$.

Constraints

  • $1 \leq N \leq 100$
  • $1 \leq A_i \leq 10^7$
  • $10^9 \leq X \leq 10^{18}$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $X$
$A_1$ $\ldots$ $A_N$

Output

Print the earliest time he can get a potion with a magic power of exactly $X$.


Sample Input 1

3 9999999999
3 6 8

Sample Output 1

4999999994

The potion made by mixing Material $1$ and Material $3$ has a magic power of $3+8=11$ at time $0$, and it increases by $2$ every second, so it will be $9999999999$ at time $4999999994$, which is the earliest possible time.

The potion made by mixing all the materials $1, 2, 3$ will have a magic power of $9999999998$ at time $3333333327$ and $10000000001$ at time $3333333328$, so it will never be exactly $9999999999$.


Sample Input 2

1 1000000000000000000
1

Sample Output 2

999999999999999999

Input

题意翻译

你是一个大魔法师,现在你手上有 $N$ 种物品,每种物品的魔法值为 $A_i$。 你在时刻零可以选择任意多的物品,初始魔法值为你选的物品的魔法值总和。 不妨记你选择了 $K$ 个物品,那么,此后每秒,总魔法值将会增加 $K$。 现在你想让总魔法值**恰好等于** $X$,求你需要花费的最小时间。 + $1\le N \le 100$ + $1 \le A_i \le 10^7$ + $10^9 \le X \le 10^{18}$ + 所有输入的都是整数 Translated by [Tx_Lcy](https://www.luogu.com.cn/user/253608)

加入题单

上一题 下一题 算法标签: