SalesforceOA #27
Maximize Sum of Processed Times
Estimated MediumJudge-ready
Topics (AI-labelled)Tree & Game DP
Tasks are assigned in order, and initially the first core holds the lock. The core holding the lock may either assign the current task to itself and hand over the lock, or assign it to the other core and keep the lock. Both sides maximize the total processing time they end up with; output the final payoffs of the first core and the second core.
Input
The input gives n and n task times. There are no original numeric bounds; this site adds 1≤n≤200000, 0≤time[i]≤10^9.
Output
Output the two integer payoffs, first core then second core, separated by a space.
Example 1
Input:
4
10 10 10 10
Output:
20 20
Example 2
Input:
5
10 15 20 25 30
Output:
55 45
Example 3
Input:
6
45 25 35 15 45 25
Output:
115 75
Example notes
The outputs of the three public examples are, in order: 20 20; 55 45; 115 75. They have been checked by independent enumeration or direct simulation.
Editorial
Loading solution…