#B4314. Reassembling the Rubik's Cube
Reassembling the Rubik's Cube
Reassembling the Rubik's Cube
A standard Rubik's Cube is composed of $8$ corner pieces, $12$ edge pieces, and $1$ center (axis).
You are given $n$ damaged Rubik's Cubes. For each cube, you are provided with three integers:
- $a$: the number of broken corner pieces,
- $e$: the number of broken edge pieces,
- $c$: a flag indicating whether the center is broken (
1
for broken,0
for intact).
The process to recycle the cubes is as follows:
- Disassemble all pieces (corners, edges, and the center) from each cube and discard any broken parts.
- Restick all remaining pieces (the original colors no longer matter).
- Reassemble complete Rubik's Cubes using $8$ corner pieces, $12$ edge pieces, and $1$ center for each cube.
Determine the maximum number of complete cubes that can be reassembled from the salvaged parts.
inputFormat
The first line contains an integer (), the number of damaged Rubik's Cubes. Each of the next lines contains three integers , , and , where:
- is the number of broken corner pieces in that cube (),
- is the number of broken edge pieces in that cube (),
- is a flag (either 0 or 1) indicating if the center is broken (1 means broken, 0 means intact).
All values are space-separated.
outputFormat
Output a single integer — the maximum number of complete Rubik's Cubes that can be reassembled from the salvaged parts.
sample
1
1 2 0
0