Maximum Server Processing Time
Learn this problemProblem statement
You are given numTasks tasks and numServer servers.
The tasks must be assigned to the servers under the following conditions:
- Each server is assigned a contiguous block of tasks.
- Every task is assigned to exactly one server.
- Each server must be assigned at least
mtasks.
The processing time of task i is processTime[i].
For any server, its processing time is the sum of the m largest processing times among the tasks assigned to that server.
The servers work sequentially: one server completes all of its assigned tasks before the next server begins.
Determine the maximum total processing time required for all servers to complete all tasks.
Complete the function getMaximumProcessingTime. The array processTime contains the processing times of the tasks, numServer is the number of servers, and m is the minimum number of tasks assigned to each server. Here, numTasks = processTime.length. Return the maximum total processing time.
Function
getMaximumProcessingTime(processTime: int[], numServer: int, m: int) → longExamples
Example 1
processTime = [1, 3, 5, 2, 7, 1, 5, 9]numServer = 3m = 2return = 31Here, numTasks = 8. A maximum-total assignment is:
- Server 1 handles tasks 1, 2, and 3. Its two largest processing times are
3and5, so its processing time is8. - Server 2 handles tasks 4, 5, and 6. Its two largest processing times are
2and7, so its processing time is9. - Server 3 handles tasks 7 and 8. Its two largest processing times are
5and9, so its processing time is14.
The total processing time is 8 + 9 + 14 = 31. Thus, the maximum total processing time is 31.
More Visa problems
- Signal PingsOA · Seen Jul 2026
- Sum of Index-Ordered Pair DifferencesOA · Seen Jul 2026
- Minimum Cost to Attend Required CoursesOA · Seen Jul 2026
- Minimum Score of a Path Between CitiesOA · Seen Jul 2026
- Planning ProductionOA · Seen Jul 2026
- Subarray SumOA · Seen Jul 2026
- Maximum Even Tag SumOA · Seen Jun 2026
- Transform Binary MatrixOA · Seen Jun 2026