Velsas
InterviewTime limit1sMemory limit1024 MB
Find the shortest contiguous run of daily route heights whose sum is at least M, or report NEPAVYKS if no such run exists.
- Level
Easy3 of 10
- Topics
- Sliding window, Two pointers, Array
- Solved
- No attempts yet
Problem
Every spring, Vladimir travels to Wales with his friends to ride bicycles.
Wales has beautiful nature. It has fast rivers, forests untouched by people, waterfalls, and mountains.
To ride in mountainous terrain, Vladimir must train. He planned a route of a fixed height for each day.
Vladimir is ready once the sum of the heights of the routes he has completed is at least meters.
If he trains without breaks, find the minimum number of days he needs to get ready for the trip. Vladimir may start training on any day.
Input
The first line contains two integers and . is the number of days, and is the sum of route heights Vladimir wants.
Each of the next lines contains one integer , the height in meters of the route planned for that day.
Output
Print one integer: the minimum number of days Vladimir needs to get ready, if he trains without breaks.
If he cannot get ready, print NEPAVYKS.