WC '16 Finals S1 - Cow-Bot Construction
View as PDF2016-17 Woburn Challenge Finals Round - Senior Division

It would seem that war is inevitable. Bo Vine's communication with his cow spy has been intercepted by the devious monkeys, confirming his suspicions that the Head Monkey is up to no good! In preparation for the impending conflict with the monkeys, Bo Vine has ordered the construction of a new, state-of-the-art Cow-Bot model from scratch.
The schematics call for  
 different modules to
be installed, in any order. Bo Vine's cow engineers require 
 minutes to install any single module. However, the
Cow-Bot (being a sophisticated, artificially intelligent piece of
hardware) may also be able to help out! If at least 
 different modules have already been installed into the
Cow-Bot up to a certain point in time, then it becomes able to install
the 
-th module into itself in 
 
 minutes.
Only one module may be in the process of being installed into the
Cow-Bot at any time, meaning that the engineers and Cow-Bot may not
simultaneously install two different modules at once.
Please help the cows determine the minimum amount of time required for
all  modules to be installed into the Cow-Bot.
In test cases worth  of the points, 
.
Input Specification
The first line of input consists of three space-separated integers ,
, and 
.
 lines follow, the 
-th of which consists of a single integer
 (for 
).
Output Specification
Output one line consisting of a single integer – the minimum number of
minutes required for all  modules to be installed into the Cow-Bot.
Sample Input
7 7 4
4
0
4
2
6
4
4
Sample Output
34
Sample Explanation
One optimal sequence of module installations is as follows (with each step's completion time indicated):
- Module 
by the Cow-Bot (
minutes)
 - Module 
by the engineers (
minutes)
 - Module 
by the engineers (
minutes)
 - Module 
by the Cow-Bot (
minutes)
 - Module 
by the Cow-Bot (
minutes)
 - Module 
by the Cow-Bot (
minutes)
 - Module 
by the Cow-Bot (
minutes)
 
Comments