You are given an array of integers `crates` representing the number of packets in each crate. Determine the maximum number of packets each crate can be filled with if the total packets are distributed evenly, and find the number of crates that will have remaining packets.
Explanation: The total number of packets is 10. The maximum number of packets each team member can receive if the packets are to be distributed evenly is the total number of packets divided by the number of crates rounded down, which is 10 // 3 = 3. However, since 3 is larger than the number of packets in the first crate, the even distribution is limited by the smallest crate. The maximum number of packets each team member can receive is the smallest number of packets in any crate, which is 2. So the total number of packets distributed is 2 * 3 = 6. The number of remaining packets is 10 - 6 = 4, which is from 2 crates (second and third crates).
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak