Problem J
Jackdaws And Crows

A comment chain is alternating if the scores
There are two operations Nick can do to make the comment chain alternating:
-
Create a fake account and upvote/downvote some of the comments. This increases/decreases their respective scores by
. Each fake account can only upvote/downvote each comment at most once, but it can vote on any subset of the comments. It takes seconds to create an account and use it to vote (regardless of how many comments are upvoted/downvoted). -
Report one specific comment to remove it from the chain. Thinking of convincing reasons for the report takes
seconds. (Nick is an excellent arguer, so once the report is filed, the comment is guaranteed to be removed.)
Nick can apply these operations in any order, any number of times. How fast can he make the comment chain alternating?
For example, consider Sample Input 1 below, where the scores
in the comment chain are
Input
The input consists of:
-
One line with three integers
, , and ( , ), the number of comments in the chain, the time it takes to create a fake account and the time it takes to report one comment respectively. -
One line with
integers ( for all ), the current score of each comment in the chain.
Output
Output the smallest time to make the comment chain alternating by applying the operations above.
Sample Input 1 | Sample Output 1 |
---|---|
4 10 50 8 8 2 -2 |
80 |
Sample Input 2 | Sample Output 2 |
---|---|
6 100 33 5 -13 0 0 -12 0 |
132 |