LCC '25 Contest 2 S2 - Reading

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 1.0s
Python 3 2.0s
Memory limit: 256M

Author:
Problem type

You are working on a project that takes K hours to finish. The project is due in N days, and you can start working on the project on any of the days from 1 to N. However, you are very busy, and on the i^{th} day, you only have 1\leq h_i\leq 24 hours where you will be able to work on the project. Additionally, once you start the project, you must work on it on all consecutive days that follow, until you finish the project. You want to figure out what day you should start the project, such that the number of days it takes you to finish the project is minimal.

Input Specification

The first line contains N,K.

The second line contains N integers, h_1,h_2,...,h_N.

Output Specification

The start day that gives the minimum days to finish the project. It is guaranteed that it is possible to finish the project in N days.

If there are multiple possible such days, output the earliest one.

Constraints

Subtask 1 [50%]

1\leq N \leq 10^5

1\leq K \leq 10^7

Subtask 2 [50%]

1\leq N \leq 2\cdot 10^7

1\leq K \leq 10^9

Sample Input 1

6 10
4 2 1 5 5 3

Output for Sample Input 1

4

Explanation of Output for Sample Input 1

You have 5 hours to work on the project on both days 4 and 5. Thus, if you start on day 4, you can finish the project in 2 days, which in this case, is the minimum possible number of days.

Sample Input 2

5 4
1 1 1 1 1

Output for Sample Input 2

1

Comments

There are no comments at the moment.