Problem F
Brick Wall
Languages
da
en
You want to build the longest possible wall using LEGO bricks. The wall must be two bricks high and one brick deep, ending neatly with flush bricks at each end. Your wall must be stable, meaning it must not have internal fracture lines where both the top and bottom rows of bricks end simultaneously.
Here is a stable wall with a width of $14$, corresponding to example $1$:
Here is an unstable wall with the same bricks; you do not want to build this:
Note that you may not be able to use all your bricks. For example, if you have one two-brick, one four-brick, and three eight-bricks, as in example $2$, then you cannot do better than stacking two of the eight-bricks on top of each other, for a width of $8$. The remaining three bricks are useless.
Input
Input consists of a single line with three integers $a$, $b$, and $c$, indicating the number of bricks of each size. The value $a$ is the number of two-bricks, $b$ is the number of four-bricks, and $c$ is the number of eight-bricks. There are at most $100$ bricks in total, so $0 \leq a + b + c \leq 100$.
Output
Write a single integer: the length of the longest stable wall you can build with the given bricks.
Sample Input 1 | Sample Output 1 |
---|---|
2 2 2 |
14 |
Sample Input 2 | Sample Output 2 |
---|---|
1 1 3 |
8 |
Sample Input 3 | Sample Output 3 |
---|---|
1 1 1 |
0 |