Woburn Challenge 2015-16 Round 1 - Senior Division
The mascot of Woburn is the Wildcat. The Woburn Wildcats are soon going
to be playing in the finals of the Scarborough Halo 2 Association
(SHA-2) and the rest of the school would like to make signs to cheer
them on. The Student Activity Council (SAC) has purchased heaps of giant
cards for the sole purpose of creating signs that spell out the word
WILDCATS
. Specifically, we can construct one such sign by combining
cards with the letters W
, I
, L
, D
, C
, A
, T
, and S
on
them, respectively.
There are two types of cards – letter cards and wildcards. Printed on
each letter card is what you would expect... a single letter that is part
of the word WILDCATS
. On the other hand, there are three types of
wildcards – the @
card, the #
card, and the *
card. A wildcard
marked with an @
may be filled in with any vowel of your choice (in
this case, either an A
or an I
). Similar, each wildcard marked with
a #
may be filled in with any consonant (in this case, one of W
,
L
, D
, C
, T
, or S
). Finally, each wildcard marked with a *
may be filled in with any letter at all!
After counting inventory, the SAC was able to come up with 11 integers,
the number of cards they have marked with W
, I
, L
, D
, C
, A
,
T
, S
, @
, #
, and *
, in that order. There are at most
of each type of card. The Woburn SAC would like you to
write a program to help them maximize the number of WILDCATS
signs
that can be made, given that you choose to fill in the wildcards
optimally.
In test cases worth 50% of the points, there will be at most of
each type of card.
In a subset of those test cases worth 10% of the points, there will be
no wildcards (the last integers of the input will each be ).
Input Specification
The input will consist of lines, each containing a single nonnegative
integer less than or equal to .
The first integers will represent the number of cards for each letter
of WILDCATS
, in the order they occur in the word.
The last integers will represent the number of @
, #
, and *
wildcards, in that order.
Output Specification
Output a single integer – the maximum number of WILDCATS
signs that
can be constructed if the wildcards are filled in optimally.
Sample Input
6
7
10
10
10
5
10
10
3
2
5
Sample Output
9
Explanation
There are W
's, I
's, A
's, and of each remaining letter
card. We fill in of our @
wildcards as I
and the remaining
as A
. We fill both of our #
wildcards as W
. Finally, we fill in
one *
wildcard as W
, one as I
, and two as A
. This will be enough
to create signs with cards to spare (namely, one each of L
, D
,
C
, T
, S
, and a *
wildcard).
Comments