Woburn Challenge 2015-16 Round 1 - Senior Division
Problem 2: Wildcat Wildcards
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 8 cards with the letters
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 a
@ 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
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
*, in that order. There are at most 108 (100,000,000) 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 1000 of each type of card.
In a subset of those test cases worth 10% of the points, there will be no wildcards (the last 3 integers of the input will each be 0).
The input will consist of 11 lines, each containing a single nonnegative integer less than or equal to 108.
The first 8 integers will represent the number of cards for each letter of "
WILDCATS", in the order they occur in the word.
The last 3 integers will represent the number of
* wildcards, in that order.
Output a single integer – the maximum number of "
WILDCATS" signs that can be constructed if the wildcards are filled in optimally.
6 7 10 10 10 5 10 10 3 2 5
There are 6
A's, and 10 of each remaining letter card. We fill in 1/3 of our
@ wildcards as
I and the remaining 2/3 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 9 signs with 6 cards to spare (namely, one each of
S, and a
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3