Lawnmower
시간 제한5초메모리 제한1024 MB
각 레인의 풀을 탱크 용량 단위로 나누고, 언제 일찍 비울지 정해 전체 이동 시간과 비우는 시간의 합을 최소로 만든다.
문제
After his adventures in Poenari Fortress, Vlad returns home and, as a true Romanian, his first thought is that he should feed his horse. The horse is not very picky when it comes to food, so Vlad uses his lawn as a primary source of food for it.
For this task, Vlad has a lawn mower of capacity . He decided to split his lawn into lanes, numbered from to , which he has to mow in this order. Each lane contains a quantity of uncut grass and, due to some unknown reasons, it takes seconds for Vlad to push the mower over that lane.
After going over a few lanes, the mower may reach full capacity, in which case it stops cutting grass, leaving some on that lane. Every time that happens, its collector tank needs to be emptied, which takes seconds and can be done only at the end of a lane. If the collector tank fills up while Vlad is going over lane , he needs to keep pushing the mower until the end of the lane, empty the tank and then go over the lane one more time (or as many times as needed) in order to cut the left-over grass. For example if for a lane we have to pass through it times to get rid of all the grass, that will take seconds. After mowing the entire lawn, the mower must be emptied.
After a lot of thinking and complaining that it will take him way too much to finish mowing, Vlad arrived at the conclusion that sometimes it might be more time-efficient to empty the collector tank even before it reaches full capacity, but he is not sure what is the best strategy he can use. Therefore, he asks for your help.
Given the quantity of grass on each lane and the number of seconds it takes to push the mower over each lane, the capacity of the tank and the time it takes to empty it, find the best way for Vlad to finish mowing his lawn in minimum time.
제한
- (for each such that )
- (for each such that )
- It is guaranteed that the correct result will be at most
예제
이 문제는 공개된 예제가 없습니다.