Mini-Tetris 3023

시간 제한2초메모리 제한1024 MB

요약
정사각형 a개, S타일 b개, 코너 c개가 주어질 때, 일부 타일로 정확히 채울 수 있는 2 x n 직사각형의 최대 너비 n을 구한다.
난이도

쉬움10점 중 3점

유형
수학, 그리디, 구현, 완전 탐색
정답자
아직 제출이 없습니다

문제

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 22 cells high and has just three types of tile:

  • A square made out of 44 tiles in a 2×22 \times 2 grid.
  • An S-tile made out of 44 tiles, 22 on one row and 22 slightly offset on the other
  • A corner made out of 33 tiles, 11 on one row and 22 on the other

Tiles may be rotated 00, 9090, 180180, or 270270 degrees to fit amongst each other, however, they cannot overlap or go outside the vertical boundary of the grid.

This game provides aa squares, bb S-tiles, and cc corners. Gry would like to beat the high score by creating the largest-possible contiguous 2×n2 \times n rectangle out of some or all of the provided tiles, without any tiles overlapping or sticking out of the rectangle.

입력

  • The sole line of input contains three integers aa, bb, and cc (0≤a,b,c≤500 \leq a, b, c \leq 50) --- the number of squares, S-tiles, and corners, respectively.

출력

Output the maximum possible width of the grid, nn, that can be perfectly filled by some or all of the given tiles without overlapping or overstepping the boundaries.

예제3

  1. 예제 1

    입력
    2 2 2
    
    예상 출력
    11
    
  2. 예제 2

    입력
    1 1 1
    
    예상 출력
    2
    
  3. 예제 3

    입력
    0 0 0
    
    예상 출력
    0