You are given an integer array modules where modules[i] is the workload of the i-th module. You must assign every module to exactly one of 3 servers. Each server's load is the sum of the workloads of the modules assigned to it.
Each server must receive at least one module. Return the maximum possible value of the minimum load across the 3 servers after an optimal assignment.
Function Signature
def max_min_server_load(modules: list[int]) -> int:
Rules
-
A module cannot be split: its whole workload goes to one server.
-
The three servers are identical, so assignments that only swap server labels count as the same assignment.
-
Return only the value of the best minimum load, not the assignment itself.
Constraints
-
3 <= len(modules) <= 20
-
1 <= modules[i] <= 10^9
Examples
Input: modules = [10,20,30,40,50,60]
Output: 70
Putting {10, 60}, {20, 50} and {30, 40} on the three servers gives every server a load of 70. The total workload is 210, so no assignment can give all three servers more than 210 / 3 = 70.
Input: modules = [1,2,3]
Output: 1
With three modules, each server gets exactly one, so the loads are 1, 2 and 3 and the minimum is 1.
Input: modules = [8,3,3,2,2]
Output: 5
The server holding the 8 has a load of at least 8, so the other two servers share at most 10 and the lighter of them gets at most 5. The assignment {8}, {3, 2}, {3, 2} reaches 5.