There are children and colored pencils. The colors are numbered from to , and there is exactly one pencil of each color.
Each child wants to draw one line with each color. Child must use the colors in the order .
Drawing one line takes exactly one minute. During each minute, each child can use at most one pencil, and each pencil can be used by at most one child. Children may wait before drawing their first line or between drawing two lines.
Find the minimum number of minutes needed for all children to finish drawing.
The children can start in minutes , , and , then each draws for four consecutive minutes. They finish in minutes , , and . The last child to use pencil cannot do so before minute and needs three more minutes, so fewer than minutes is impossible.
All four children can draw without waiting. In each minute, they use four different pencils, so everyone finishes after minutes. Each child needs four lines, so this is optimal.
One schedule is shown below. A dash means that the child does not draw during that minute.
| Child | Minute 1 | Minute 2 | Minute 3 | Minute 4 | Minute 5 | Minute 6 | Minute 7 |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 2 | - | 3 | 4 | - | - |
| 2 | - | 1 | 2 | - | 3 | 4 | - |
| 3 | - | - | 1 | 2 | - | 3 | 4 |
| 4 | 3 | 4 | - | 1 | 2 | - | - |
| 5 | - | 3 | 4 | - | 1 | 2 | - |
| 6 | - | - | 3 | 4 | - | 1 | 2 |
Every child still needs at least one line after using pencil . That pencil must be used six times, so the last of these uses cannot finish before minute . At least minutes are necessary.
The only child uses colors in five consecutive minutes. Five lines require at least minutes.
The children take turns using the only pencil. Exactly minutes are needed.