3961. Maximize Sum of Device Ratings
You are given a 2D integer array
unitsof sizem × nwhereunits[i][j]represents the capacity of thej^thunit in thei^thdevice. Each device contains exactlynunits.The rating of a device is the minimum capacity among all its units.
You may perform the following operation any number of times (including zero):
- Choose a device
ithat has not been used as a source before.- Remove exactly one unit from device
iand add it to any different device.- Then mark device
ias used, so it cannot be chosen again as a source.Return the maximum possible sum of the ratings of all devices after any number of such operations.
Note:
- Devices can receive units from multiple devices, regardless of whether they have been selected.
- The rating of an empty device is 0.
1 | class Solution { |