Type an input and write what you think is the output . Each problem is converted to Web Assembly, so any possible input will show the corresponding output. Only correct predictions count.
Locked until you have predicted 5 outputs correctly.
| 1 | int solution(const vector<int>& nums, int h) { |
| 2 | |
| 3 | int lo = 1; |
| 4 | int hi = *max_element(nums.begin(), nums.end()); |
| 5 | |
| 6 | while (lo < hi) { |
| 7 | |
| 8 | int mid = lo + (hi - lo) / 2; |
| 9 | long long hours = 0; |
| 10 | |
| 11 | for (int x : nums) { |
| 12 | hours += (x + mid - 1) / mid; |
| 13 | } |
| 14 | |
| 15 | if (hours <= h) { |
| 16 | hi = mid; |
| 17 | } else { |
| 18 | lo = mid + 1; |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | return lo; |
| 23 | } |
Names have been stripped. The signature is the only clue you get for free. Compiled as C++20 with the standard headers and using namespace std; already in scope.