diff --git a/1760_Minimum_Limit_of_Balls_in_a_Bag.cpp b/1760_Minimum_Limit_of_Balls_in_a_Bag.cpp new file mode 100644 index 0000000..51c6b4e --- /dev/null +++ b/1760_Minimum_Limit_of_Balls_in_a_Bag.cpp @@ -0,0 +1,34 @@ +// ███████╗ █████╗ ███╗ ██╗ ██████╗ █████╗ ██████╗ ██████╗ ██╗ ██╗ +// ██╔════╝ ██╔══██╗ ████╗ ██║ ██╔══██╗ ██╔══██╗ ██╔══██╗ ██╔══██╗ ██║ ██║ +// ███████╗ ███████║ ██╔██╗ ██║ ██║ ██║ ███████║ ██████╔╝ ██████╔╝ ███████║ +// ╚════██║ ██╔══██║ ██║╚██╗██║ ██║ ██║ ██╔══██║ ██╔═██╗ ██╔══██╗ ██╔══██║ +// ███████║ ██║ ██║ ██║ ╚████║ ██████╔╝ ██║ ██║ ██║ ██╗ ██████╔╝ ██║ ██║ +// ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ +#pragma GCC optimize("Ofast", "inline", "ffast-math", "unroll-loops","no-stack-protector") +#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native", "f16c") +auto init = []() { + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); + return 'c'; +}(); +class Solution { +public: + int minimumSize(vector& nums, int maxOperations) { + int s =1, e = *max_element(nums.begin(), nums.end()); + while(s>1; + long long cnt = 0; + for (int x : nums) { + cnt += (x - 1) / mid; + } + if(cnt <= maxOperations){ + e = mid; + } + else{ + s = mid+1; + } + } + return s; + } +};