Lawnmower

시간 제한5초메모리 제한1024 MB

요약
각 레인의 풀을 탱크 용량 단위로 나누고, 언제 일찍 비울지 정해 전체 이동 시간과 비우는 시간의 합을 최소로 만든다.
난이도

보통10점 중 7점

유형
그리디, 동적 계획법
정답자
아직 제출이 없습니다

문제

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 cc. He decided to split his lawn into nn lanes, numbered from 00 to n−1n − 1, which he has to mow in this order. Each lane ii contains a quantity of uncut grass v\[i]v\[i] and, due to some unknown reasons, it takes a\[i]a\[i] 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 bb seconds and can be done only at the end of a lane. If the collector tank fills up while Vlad is going over lane ii, 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 ii we have to pass through it 33 times to get rid of all the grass, that will take a\[i]+b+a\[i]+b+a\[i]a\[i] + b + a\[i] + b + a\[i] 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.

제한

  • 1≤n≤200,0001 ≤ n ≤ 200\\, 000
  • 1≤a\[i]≤1091 ≤ a\[i] ≤ 10^9 (for each ii such that 0≤i<n0 ≤ i < n)
  • 1≤v\[i]≤1091 ≤ v\[i] ≤ 10^9 (for each ii such that 0≤i<n0 ≤ i < n)
  • 1≤b≤1091 ≤ b ≤ 10^9
  • 1≤c≤1091 ≤ c ≤ 10^9
  • It is guaranteed that the correct result will be at most 101810^{18}

예제

이 문제는 공개된 예제가 없습니다.