2026牛客国庆集训派对day6
B
Crash Test
牛客竞赛
未评级
原题
← AC →

Crash Test官方中文

题目描述

官方中文

After five years, the most high-profile event in motor racing, Formula 1, returns to China. The Chinese Grand Prix was recently held at the Shanghai International Circuit. Formula 1 cars can reach speeds of up to 350 km/h. To ensure the safety of the drivers, the cars must pass rigorous crash tests. We consider the following simplified version of a crash test. Initially, a car is positioned with its front facing a wall, at a distance of $D$ meters from the wall. This crash test provides $n$ types of boosters, where the $i$-th type of booster has a thrust performance of $h_i$, and there are ample quantities of each type of booster. Suppose the current distance between the car's front and the wall is $d$, and we use a booster with a thrust performance of $h$. When $d \ge h$, the car will move forward $h$ meters and then stop. Otherwise, the car will move forward $d$ meters, crash into the wall, and rebound $h-d$ meters, after which it stops, still facing the wall. Now, you want to know, through any number of operations (including no operation), what the minimum distance between the car's front and the wall can be?官方中文

输入格式

官方中文

The first line of input contains two positive integers $n$ and $D$ ($1 \le n \le 100, 1 \le D \le 10^{18}$), denoting the number of boosters and the distance between the Formula 1 car and the wall, respectively.官方中文

The second line of inputcontains $n$ positive integers $h_1, h_2, \ldots, h_n$ ($1 \le h_i \le 10^{18}$), denoting the thrust performance of each booster.官方中文

输出格式

官方中文

Output an integer in a line, denoting the minimum possible distance between the car's front and the wall.
官方中文

样例

Input #1
1 10
3
Output #1
1
An optimal strategy is $10 \overset{i = 1}{\rightarrow} 7 \overset{i = 1}{\rightarrow} 4 \overset{i = 1}{\rightarrow} 1$.
Input #2
2 10
3 4
Output #2
0
An optimal strategy is $10 \overset{i = 1}{\rightarrow} 7 \overset{i = 2}{\rightarrow} 3 \overset{i = 1}{\rightarrow} 0$.
Input #3
2 1
3 7
Output #3
0
An optimal strategy is $1 \overset{i = 2}{\rightarrow} 6 \overset{i = 1}{\rightarrow} 3 \overset{i = 1}{\rightarrow} 0$.
Input #4
10 4306315981482911
4306 3519 8148 2911 9970 7222 5462 1844 7072 1702
Output #4
0
Input #5
10 123456789987654321
10 10 10 10 10 10 10 10 10 10
Output #5
1
题目信息
题号
nc140734pb
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 牛客竞赛 及出题人所有;中文翻译由 AI 生成(官方原文),如有出入请以原文为准。