GPU Capacity With Limited Cluster Switching
Problem statement
You operate several GPU clusters for a sequence of days. Cluster c has a fixed capacity capacities[c]. Each row [day, cluster, used] records the GPUs already occupied on that day; an omitted pair has zero usage.
Choose exactly one cluster per day. Its contribution is capacity - used. Moving from one cluster to a different cluster between consecutive days consumes one switch. Return the maximum total remaining GPU capacity obtainable with at most maxSwitches switches.
Every day and cluster pair appears at most once in usages.
Function
maximizeRemainingGpu(capacities: int[], numDays: int, usages: int[][], maxSwitches: int) → intExamples
Example 1
capacities = [10,8]numDays = 3usages = [[0,0,9],[0,1,1],[1,0,0],[1,1,7],[2,0,9],[2,1,0]]maxSwitches = 1return = 19Use cluster 1 on day 0, switch to cluster 0 on day 1, and remain there on day 2 for 7 + 10 + 1 = 18.
Example 2
capacities = [5,9]numDays = 2usages = []maxSwitches = 0return = 18With no switches, staying on cluster 1 contributes 9 on each day.
Constraints
1 <= capacities.length <= 501 <= numDays <= 2000 <= maxSwitches < numDays0 <= used <= capacities[cluster] <= 10000