Split Bags to Minimize the Largest Bag. nums[i] is the number of balls in one bag. One operation replaces a bag by two bags containing positive numbers of balls. Perform at most maxOperations splits and return the smallest possible largest bag size.
### Problem
`nums[i]` is the number of balls in one bag. One operation replaces a bag by two bags containing positive numbers of balls. Perform at most `maxOperations` splits and return the smallest possible largest bag size.
```cpp
class Solution {
public:
int minimumSize(vector<int>& nums, int maxOperations);
};
```
### Examples
**Example 1:**
```text
nums = [10], maxOperations = 3
Output: 3
Explanation: Four bags of sizes 3, 3, 2, and 2 are possible. A maximum of 2 would need five bags and four splits.
```
**Example 2:**
```text
nums = [3,7], maxOperations = 2
Output: 3
Explanation: Split 7 into 3, 2, and 2, leaving the original 3.
```
### Constraints
- `1 <= nums.length <= 10^5`.
- `1 <= maxOperations <= 10^9`.
- `1 <= nums[i] <= 10^9`.
### Clarifying Questions
Each split increases the bag count by one. Empty bags are forbidden, and bags cannot be merged.
```hint Inspect the structure
Which operations change the number of bags, and what must remain true about every bag's contents?
```
### Reasoning checkpoints
- Show that the proposed final bag sizes are positive and reachable within the split budget.
- Prove that no smaller largest bag size is feasible.
### Optional extensions
What construction realizes the minimum required splits for each original bag?
Overview: Split Bags to Minimize the Largest Bag. nums[i] is the number of balls in one bag. One operation replaces a bag by two bags containing positive numbers of balls. Perform at most maxOperations splits and return the smallest possible largest bag size.
nums[i] is the number of balls in one bag. One operation replaces a bag by two bags containing positive numbers of balls. Perform at most maxOperations splits and return the smallest possible largest bag size.
class Solution {
public:
int minimumSize(vector<int>& nums, int maxOperations);
};
Examples
Example 1:
nums = [10], maxOperations = 3
Output: 3
Explanation: Four bags of sizes 3, 3, 2, and 2 are possible. A maximum of 2 would need five bags and four splits.
Example 2:
nums = [3,7], maxOperations = 2
Output: 3
Explanation: Split 7 into 3, 2, and 2, leaving the original 3.
Constraints
1 <= nums.length <= 10^5
.
1 <= maxOperations <= 10^9
.
1 <= nums[i] <= 10^9
.
Clarifying Questions Guidance
Each split increases the bag count by one. Empty bags are forbidden, and bags cannot be merged.
Reasoning checkpoints
Show that the proposed final bag sizes are positive and reachable within the split budget.
Prove that no smaller largest bag size is feasible.
Optional extensions
What construction realizes the minimum required splits for each original bag?