you give 0indexed integer array server task length n m respectively serversi weight ith server tasksj time need process jth task secondstask assign server task queue Initially server free queue emptyAt second j jth task insert queue start 0th task insert second 0 as long free server queue task queue assign free server small weight case tie assign free server small indexIf free server queue wait server free immediately assign task if multiple server free time multiple task queue assign order insertion follow weight index priority aboveA server assign task j second t free second t tasksjbuild array ans length m ansj index server jth task assign toReturn array an Example 1input server 332 task 123212output 220212explanation event chronological order follow at second 0 task 0 add process server 2 second 1 at second 1 server 2 free Task 1 add process server 2 second 3 at second 2 task 2 add process server 0 second 5 at second 3 server 2 free task 3 add process server 2 second 5 at second 4 task 4 add process server 1 second 5 at second 5 server free Task 5 add process server 2 second 7example 2input server 51432 task 2124521output 1414132explanation event chronological order follow at second 0 task 0 add process server 1 second 2 at second 1 task 1 add process server 4 second 2 at second 2 server 1 4 free Task 2 add process server 1 second 4 at second 3 task 3 add process server 4 second 7 at second 4 server 1 free Task 4 add process server 1 second 9 at second 5 task 5 add process server 3 second 7 at second 6 task 6 add process server 2 second 7 constraintsserverslength ntaskslength m1 n m 2 1051 serversi tasksj 2 105