There is a dual-core processor with one process queue for each core. There are n
processes, where the time to process the i
th process is denoted by time(i)
(1 โค i
โค n
). There is a latch that helps decide which process is processed by which core. Initially, the first core has the latch. Suppose the latch is currently with the c
th core, where c
is either 1 or 2, and the i
th process needs to be assigned. Then one of the following operations must be performed:
i
th process is assigned to the core c
, and the latch is given to the other core.i
th process is assigned to the other core, and the latch is retained by the 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.
Find the sum of the time of processes assigned to the first and second cores if both the cores work optimally. Return an array of two integers, where the first integer is the sum of the time of processes assigned to the first core, and the second integer is the sum of the time of processes assigned to the second core.
Example 1:
Input: times = [10, 10, 10, 10]
Output: [20, 20]
Explanation:Both cores will have processes with equal sum of times, which is 20.
Example 2:
Input: times = [1, 2, 3, 4]
Output: [5, 5]
Explanation:Both cores will have processes with equal sum of times, which is 5.
Example 3:
Input: times = [10, 15, 20, 25, 30]
Output: [55, 45]
Explanation:The first core will have processes with sum of times 55, and the second core will have 45.
Example 4:
Input: times = [45, 25, 35, 15, 45, 25]
Output: [115, 75]
Explanation:The first core will have processes with sum of times 115, and the second core will have 75.
Example 5:
Input: times = [40, 20, 30, 10]
Output: [70, 30]
Explanation:The first core will have processes with sum of times 70, and the second core will have 30.
๐๐

input:
output: