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
![\includegraphics[width=.3\textwidth ]{stable.pdf}](/problems/brikmur/file/statement/en/img-0001.png)
Here is an unstable wall with the same bricks; you do not want to build this:
![\includegraphics[width=.3\textwidth ]{unstable.pdf}](/problems/brikmur/file/statement/en/img-0002.png)
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
![\includegraphics[width=.15\textwidth ]{fig88.pdf}](/problems/brikmur/file/statement/en/img-0003.png)
Input
Input consists of a single line with three integers
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 |