You are given an integer array `costs` of length `n`, where `costs[i]` represents the time multiplier for the `i`-th processor to process a single task. You are also given an integer `k` representing the total number of tasks to be distributed. You must distribute all `k` tasks among the `n` processors such that each processor is assigned a non-negative integer number of tasks, and the sum of tasks assigned to all processors is exactly `k`. If processor `i` is assigned $x_i$ tasks, its total execution time is $x_i \times \text{costs}[i]$. Return the minimum possible maximum execution time among all processors after an optimal distribution of tasks.
Explanation: To minimize the maximum time taken in any lane, we distribute vehicles such that the maximum load is minimized. Using binary search, the minimum maximum load is 6 (Lane 1: 3 vehicles * 2s = 6s, Lane 2: 2 vehicles * 3s = 6s, Lane 3: 1 vehicle * 5s = 5s).
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak