Minimized Maximum of Products Distributed to Any Store
You have n retail stores and an array quantities where quantities[i] is the number of products of the ith type. Distribute all products so each store receives products of at most one type (a store may receive 0). Let x be the maximum number of products any single store receives. Return the minimum possible value of x.
Open official problem prompt ↗Find the smallest possible value for the busiest store's load, given that every store handles a single product type and only n stores exist.
You are bottling several flavors of juice into bottles of a fixed capacity, and you only own n bottles. Bigger bottles mean fewer bottles are needed. You want the smallest bottle size such that all the juice still fits in n bottles.
- Input
- n = 6, quantities = [11, 6]
- Output
- 3
- Why
- With cap 3, type 11 needs ceil(11/3)=4 stores and type 6 needs ceil(6/3)=2 stores, totaling 6 stores, which fits n=6; no smaller cap fits.
m == quantities.length1 <= m <= n <= 10^51 <= quantities[i] <= 10^5