Mini-Tetris 3023
Time limit2sMemory limit1024 MB
Given counts of square, S-tile, and corner tiles, find the widest 2 x n rectangle that some or all of them can tile exactly without overlap.
- Level
Medium4 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
A guy named Gry found a new game called "Mini-Tetris 3023". This small version of Tetris is played on a very long grid only cells high. It has just three types of tile:
- A
squaremade out of tiles in a grid. - An
S-tilemade out of tiles, on one row and slightly offset on the other. - A
cornermade out of tiles, on one row and on the other.
Tiles may be rotated , , , or degrees to fit amongst each other. However, they cannot overlap or go outside the vertical boundary of the grid.

This game provides squares, S-tiles, and corners. Gry would like to beat the high score by creating the largest possible contiguous rectangle out of some or all of the provided tiles, without any tiles overlapping or sticking out of the rectangle.
Input
The sole line of input contains three integers , , and (): the number of squares, S-tiles, and corners, respectively.
Output
Output the maximum possible width of the grid, , that can be perfectly filled by some or all of the given tiles without overlapping or overstepping the boundaries.