cswork / OAOpen practice workspace

AgodaOA #1

Maximize Sum of Processed Times

Estimated MediumStatement and editorial — judging is being prepared

Topics (AI-labelled)Tree & Game DP

There is a dual core processor with one queue for each core. There are n processes, where the time to complete the i-th process is denoted by time[i] (0 ≤ i < n). One core holds a "latch" at any moment. When assigning the i-th process, the holder of the latch picks one of two operations:

  • The i-th process is assigned to the core c (latch holder), and the latch is given to the other core.
  • The i-th process is assigned to the other core, and the latch is retained by core c. The aim of each core is to have a maximum sum of time of processes with them for better performance. So, while assigning the (i)th process, the core with the latch decides the operation to be performed such that the total sum of time of processes assigned to it is maximized after all the processes are assigned. Return the sum of time taken by the first process and the second process i.e. S1 and S2 in an array. Function Description Complete the function maximizeSumOfProcessedTimes in the editor. maximizeSumOfProcessedTimes has the following parameter:
  • int[] time: an array of integers representing the time to complete each process Returns int[]: an array of two integers representing the sum of time taken by the first and second process respectively

Editorial

Loading solution…