All problems

Problem 874

Minimum Speed to Arrive on Time

Medium · 20 pts · Array, Binary Search

Problem

You must take N trains in order; train i travels DIST[i] km. All trains move at the same integer speed you choose. Trains depart only at whole hours, so after every ride except the last you wait until the next integer hour. Find the minimum integer speed (at most 10^7) that gets you to the office within HOUR hours, or -1. HOUR has at most two digits after the decimal point; compare times exactly using hundredths of an hour.

Input

The first line contains N and HOUR. The second line contains the N distances.

Output

Print the minimum speed, or -1 if no speed up to 10^7 is enough.

Constraints

1 <= N <= 100000; 1 <= DIST[i] <= 100000; 1 <= HOUR <= 10^9 with at most two decimal places

Example input

3 6
1 3 2

Example output

1

Explanation

With distances 1 3 2 and HOUR = 6, speed 1 takes 1 + 3 + 2 = 6 hours exactly, which is allowed. So the answer is 1.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Minimized Maximum of Products Distributed to Any Store Next: Sum of Mutated Array Closest to Target