WC '15 Contest 1 S2 - Wildcat Wildcards

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 0.6s
Memory limit: 16M

Authors:
Problem types
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 8 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 10^8 (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 1\,000 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).

Input Specification

The input will consist of 11 lines, each containing a single nonnegative integer less than or equal to 10^8.
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 @, #, 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 6 W's, 7 I's, 5 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 L, D, C, T, S, and a * wildcard).


Comments

There are no comments at the moment.