传统题 1000ms 256MiB

Irahc inside Icy Caves

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

Irahc is an experienced explorer leading an expedition trapped in a vast icy cave system. The team has mm members (including Irahc). The caves form a straight line of nn connected chambers, each capable of sheltering a certain number of team members. Some chambers are so small that they cannot accommodate even a single person. Specifically, the ii-th chamber can house aia_i members.

The entire expedition team, including Irahc, must be assigned to these chambers. As the team leader, Irahc wants to minimize the distance to the farthest member from himself, measured by the number of caves between them along the line.

As Irahc's assistant, you need to determine the smallest possible maximum distance between Irahc and any other team member.

If it is impossible to house all members in the available caves, output -1\texttt{-1}.

Format

Input

The first line contains two integers n,m(1n106,1m109)n,m\,(1\leq n\leq 10^6, 1\leq m\leq 10^9), the number of chambers and the number of team members.

The second line contains nn integers a1,a2,,an(0ai106)a_1,a_2,\ldots,a_n\,(0\leq a_i\leq 10^6), where aia_i is the capacity of the ii-th chamber.

Output

Only one integer: the smallest possible maximum distance between Irahc and any other team member. Or -1\texttt{-1}, if it is impossible to house all members.

Samples

2 3
1 1
-1
3 2
1 0 1
2

Hello ACM 2025

未参加
状态
已结束
规则
ACM/ICPC
题目
11
开始于
2025-8-14 13:00
结束于
2025-8-14 18:00
持续时间
5 小时
主持人
参赛人数
46