diff --git a/1760. Minimum Limit of Balls in a Bag b/1760. Minimum Limit of Balls in a Bag new file mode 100644 index 0000000..07c02ed --- /dev/null +++ b/1760. Minimum Limit of Balls in a Bag @@ -0,0 +1,13 @@ +class Solution { +public: + int minimumSize(vector& nums, int maxOps) { + int low = 1, high = *max_element(nums.begin(), nums.end()); + while (low < high) { + int mid = low + (high - low) / 2; + int ops = 0; + for (int n : nums) if ((ops += (n - 1) / mid) > maxOps) break; + ops <= maxOps ? high = mid : low = mid + 1; + } + return high; + } +};