Woburn Challenge 2016-17 Round 3 - Junior Division

You've been hooked on the latest game in the Pokémon series, Pokémon
Navy Green, and have finally reached the final challenge! In the
original game, this challenge would've been the Elite
You've brought just two Pokémon with you to get the job done, Aeroxis
and Brinoble – you've trained both to be incredibly powerful, so they're
all you'll need. You initially have Aeroxis as your active Pokémon, with
Brinoble stored away in a backup Pokéball. Before each of the
Some members of the Elite
Given that you optimally choose when to swap Pokémon, what's the minimum
total amount of time required to defeat all
In test cases worth
Input Specification
The first line of input consists of five space-separated integers
Output Specification
Output a single line consisting of a single integer – the minimum total
amount of time required to defeat the Elite
Note that the answer may not necessarily fit within a long long
type in C++, or long
in Java).
Sample Input
20 5 5 2 5
5
6
11
17
19
Sample Output
91
Sample Explanation
One optimal strategy is as follows:
- Swap to Brinboble before the
st battle ( seconds). - Use Brinboble for battles
( seconds). - Swap to Aeroxis (
seconds). - Use Aeroxis for battles
( seconds). - Swap to Brinboble (
seconds). - Use Brinboble for battles
( seconds). - Swap to Aeroxis (
seconds). - Use Aeroxis for battle
( seconds). - Swap to Brinboble (
seconds). - Use Brinboble for battles
( seconds). - Swap to Aeroxis (
seconds). - Use Aeroxis for battles
( seconds).
Comments