Woburn Challenge 2018-19 Finals Round - Senior Division

The cows and monkeys of Scarberia, their long-standing conflicts well behind them at last, have banded together to produce a historical drama documenting their past battles. With the Head Monkey as writer and producer, and the director's chair occupied by the cows' leader, Bo Vine, this will be a collaborative masterpiece to remember!
Today, a full day of filming is set to take place at the monkeys' and
cows' joint studios. The studios feature three sound stages, numbered
from
A sequence of
What's the minimum total cost of stagehand tips which Bo Vine will need
to dispense such that each of the
Input Specification
The first line of input consists of three space-separated integers,
The next line consists of a single integer,
Output Specification
Output a single integer, the minimum total cost of stagehand tips required, in dollars.
Sample Input
6 3 4
5
3
2
2
1
2
Sample Output
17
Sample Explanation
One possible optimal strategy for Bo Vine is as follows:
- Before the
st shot, move all pieces of equipment from stage to stage . - Before the
nd shot, move all pieces of equipment from stage to stage , and all pieces of equipment from stage to stage .
This requires
Comments