Greedy Scheduler
InterviewTime limit1sMemory limit1024 MB
Assign each customer to the cashier who becomes free first, breaking ties by the smaller cashier number, and print that cashier's number for each customer.
- Level
Medium4 of 10
- Topics
- Heap, Greedy, Simulation
- Solved
- No attempts yet
Problem
A store has cashiers numbered from 1 to , and customers are waiting in a queue. The customer at the front of the queue is always assigned to the first unoccupied cashier, meaning the one with the smallest number. The th customer's shopping cart takes seconds to process.
For each customer, find which cashier processes their cart.
Input
The first line contains a single integer , the number of datasets. Each dataset has two lines. The first line contains two space-separated integers and (). The second line contains space-separated integers .
Output
For each dataset, print on a single line integers separated by single spaces. Each integer is the number of the cashier that handles that customer.