You are managing k servers, numbered from 0 to k−1, where each server can process only one request at a time, but can process unlimited requests over time.
You receive a list of incoming requests, where:
arrival[i] → time when the i-th request comes
load[i] → duration needed to complete that request
A request must be assigned using this rule:
Start checking from server i % k.
If that server is free at arrival time, assign the request to it.
Otherwise, move forward one server at a time (circular manner) until a free server is found.
If no server is free, the request is ignored.
Your goal is to determine which servers handled the most total requests.
Return their indices in any order.
Input: k = 2 arrival = [1,5,5,6] load = [4,2,3,2]
Output: [0]
Explanation:
Server 0 handles request 0. Request 1 goes to server 1. Request 2 arrives but both are busy → dropped. Request 3 goes to server 0. Server 0 handled 2 requests, more than server 1.
Input: k = 4 arrival = [2,4,6,8,10] load = [3,3,3,3,3]
Output: [0,1,2,3]
Explanation:
Every request arrives exactly when the previous one finishes. All servers process exactly one request each. Therefore, all servers are equally busy.
Input: k = 5 arrival = [1,2,10,12,13] load = [5,3,1,1,1]
Output: [2,3,4]
Explanation:
- Requests 2,3,4 go to servers 2,3,4 respectively. - They each handle one request. - No other server processes any request.
Accepted:
Submission: