FastPrepFastPrep
Problem Brief

Minimize Maximum Parcels

NEW GRADINTERNOA

You are give:

  • An integer array packages[i], where each element represents the number of packages currently assigned to the i-th delivery center.
  • An integer extra_packages, which denotes the total number of additional packages that must be distributed among the delivery centers.
  • Our mission this time is to help the company calculate the minimum possible value of the maximum number of packages assigned to any delivery center after distributing all the extra packages optimally.

    1Example 1

    Input
    packages = [7, 5, 1, 9, 1], extra_packages = 25
    Output
    10
    Explanation
    Example 1 illustration
    There are other possible optimal assignments, but the minimum value of the maximum value of the maximum number of pacakges any delivery center will deliver is 10. (Updated on 2025-01-19)

    2Example 2

    Input
    packages = [1, 2, 3], extra_packages = 3
    Output
    3
    Explanation
    Assign two extra pacakges to the 1st delivery center and one extra to the second center. Eventually, each center will have to send three packages. (Added on 2025-02-15)

    3Example 3

    Input
    packages = [1], extra_packages = 3
    Output
    4
    Explanation
    Because we have only 1 delivery center, all the extra packages will be assigned to the same :) (Added on 2025-02-15)

    Constraints

    Limits and guarantees your solution can rely on.

  • 1 <= n <= 10^5
  • 1 <= extra_packages <= 10^15
  • 1 <= packages[i] <= 10^9
  • constraints added on 01-27-2025
  • public int minimizeMaximumParcels(int[] packages, int extraParcels) {
      // write your code here
    }
    
    Input

    packages

    [7, 5, 1, 9, 1]

    extra_packages

    25

    Output

    10

    Sign in to submit your solution.