There is a park with m sketch artists (when you sit down and pay for someone to draw you) sitting in a circle. There is a manager that allocates buyers to artists. Each buyer comes at a particular timestamp and needs to be sketched for an individual duration. The manager allocates the ith buyer to the i % m artist. If that artist is occupied, the manager allocates the buyer to the first unoccupied artist to the right of i % m (keep in mind they are in a circle, so can cycle back to the beginning of the circle if needed). If all artists are occupied, the buyer just leaves and is not processed
Given the number of artists (m) sorted timestamps (T) and corresponding durations (D), find the artist with the maximum number of buyers allocated to them.
For example, say m = 3, T = [1, 2, 5, 6, 7], D=[8, 8, 2, 8, 8]
To demonstrate what happens, let's represent the occupation of the artists as a list of timestamps until they become free.
Processing i=0, current timestamp is 1, we allocate buyer 0 to artist 0, artists occupation: [9, 0, 0]
Processing i=1, current timestamp is 2, we allocate buyer 1 to artist 1, artists occupation: [9, 10, 0]
Processing i=2, current timestamp is 5, we allocate buyer 2 to artist 2, artists occupation: [9, 10, 7]
Processing i=3, current timestamp is 6, the buyer is not allocated to any artist, artists occupation: [9, 10, 7]
Processing i=4, current timestamp is 7, we cannot allocate buyer 4 to artist 1, but we can allocate buyer 4 to artist 2, artists occupation is [9, 10, 15]
The answer is artist 2, who sketched 2 buyers.
Can we find a solution that runs in faster than O(T * m)?