Problem p03840 - Generation 1

Orig Description

Score : 600 points
Problem StatementA tetromino is a figure formed by joining four squares edge to edge.
We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively:
Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively.
Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide.
Here, the following rules must be followed:
When placing each tetromino, rotation is allowed, but reflection is not.
Each square in the rectangle must be covered by exactly one tetromino.
No part of each tetromino may be outside the rectangle.
Snuke wants to form as large a rectangle as possible.
Find the maximum possible value of K.
Constraints
0≤a_I,a_O,a_T,a_J,a_L,a_S,a_Z≤10^9
a_I+a_O+a_T+a_J+a_L+a_S+a_Z≥1
InputThe input is given from Standard Input in the following format:
a_I a_O a_T a_J a_L a_S a_Z
OutputPrint the maximum possible value of K. If no rectangle can be formed, print 0.
Sample Input 12 1 1 0 0 0 0
Sample Output 13
One possible way to form the largest rectangle is shown in the following figure:
Sample Input 20 0 10 0 0 0 0
Sample Output 20
No rectangle can be formed.

Extracted Specification

An integer a_I (0 ≤ a_I ≤ 10^9).
An integer a_O (0 ≤ a_O ≤ 10^9).
An integer a_T (0 ≤ a_T ≤ 10^9).
An integer a_J (0 ≤ a_J ≤ 10^9).
An integer a_L (0 ≤ a_L ≤ 10^9).
An integer a_S (0 ≤ a_S ≤ 10^9).
An integer a_Z (0 ≤ a_Z ≤ 10^9).

### Example Input:

```
12 1 1 0 0 0 0
```

### Function Signature:
Write a function f(inputs) that takes in the input.
```python
def f(inputs: Tuple[int, int, int, int, int, int, int]):
    '''
    inputs: a tuple of seven integers
    '''
```

Test Case Generator

Certainly! Here is a Python function to generate test cases for the given problem statement:

```python
import random

def tcgen():
    # Generate random counts for each type of tetromino
    a_I = random.randint(0, 10**9)
    a_O = random.randint(0, 10**9)
    a_T = random.randint(0, 10**9)
    a_J = random.randint(0, 10**9)
    a_L = random.randint(0, 10**9)
    a_S = random.randint(0, 10**9)
    a_Z = random.randint(0, 10**9)
    
    # Ensure that there is at least one tetromino
    if a_I + a_O + a_T + a_J + a_L + a_S + a_Z == 0:
        tetromino_type = random.choice(['a_I', 'a_O', 'a_T', 'a_J', 'a_L', 'a_S', 'a_Z'])
        if tetromino_type == 'a_I':
            a_I = 1
        elif tetromino_type == 'a_O':
            a_O = 1
        elif tetromino_type == 'a_T':
            a_T = 1
        elif tetromino_type == 'a_J':
            a_J = 1
        elif tetromino_type == 'a_L':
            a_L = 1
        elif tetromino_type == 'a_S':
            a_S = 1
        elif tetromino_type == 'a_Z':
            a_Z = 1

    # Return the generated test case
    return a_I, a_O, a_T, a_J, a_L, a_S, a_Z

# Example usage:
for _ in range(5):
    print(tcgen())
```

This function generates random values for each of the tetromino counts within the given constraints. It ensures that the sum of all the tetromino counts is at least one by setting at least one of the tetromino counts to 1 if they all sum to zero. The generated test cases can be used to test the solution to the problem statement.

Extract Arguments

def extract_arguments(fh):
    a_I, a_O, a_T, a_J, a_L, a_S, a_Z = map(int, fh.readline().strip().split())
    return (a_I, a_O, a_T, a_J, a_L, a_S, a_Z)