Glitch · Medium CodeFree
Sleeping Arrangements
A queue of stretched-out dachshunds boards the night train. They must sleep in queue order, in at most K identical compartments. How short can the compartments be?
Find the shortest compartment length L, and one way to split the queue.
L must be the shortest possible, and your groups must fit in it.
N K, the dogs in the queue and the compartments on the train.N, in queue order.L. Line 2: g, the compartments used (at most K).g numbers, the last dog in each compartment, growing, the last one N.K ≤ N ≤ 100 0007 3 4 2 7 3 5 1 6
12 3 2 4 7
Sign in to play. It is free.
Sign in