Loading...
Loading...
Loading...
One packer handles several orders. In each turn the packer takes the order at the front of the line and packs at most q items of it. If items are still left, the order goes to the back of the line. Print the order ids in the order they are finished.
Example
Input
3 2 A 5 B 1 C 3
Output
B C A
B finishes in turn 2, C in turn 5 and A in turn 6.
Try the problem first. Open one hint at a time.
Keep the orders in a queue of objects that remember their items left.
Per turn: poll the front order, subtract Math.min(q, left), and print its id if nothing is left.
If items are left, offer the same order back to the end of the queue.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor