Problem · Array
Server Management
Learn this problemProblem statement
A company has n servers. For server i, serverCapacity[i] is its capacity and incomingRequests[i] is the number of requests arriving at that server.
Without an upgrade, server i can handle at most min(serverCapacity[i], incomingRequests[i]) requests.
Choose exactly k servers and double their capacities. Return the maximum total number of requests that can be handled across all servers after these upgrades.
Function
maximumHandledRequests(serverCapacity: int[], incomingRequests: int[], k: int) → longExamples
Example 1
serverCapacity = [10,4,3,7]incomingRequests = [3,10,4,5]k = 2return = 20Double the capacities of servers 1 and 2, using zero-based indices. The four servers can then handle 3, 8, 4, and 5 requests, for a total of 20.
Constraints
1 <= k <= serverCapacity.length <= 2 * 10^5serverCapacity.length == incomingRequests.length1 <= serverCapacity[i], incomingRequests[i] <= 10^9