Cleaning Windows

Binary Search Contest Easy

A building has n floors, with the ith floor having windows[i-1] windows to clean. A worker has h hours to clean all windows.


Return the minimum number of windows he has to clean each hour to finish the job within the deadline. If his speed is k windows/hour and he is on a floor with less than k windows, he will clean those windows and not go to another floor till the hour is complete. If it cannot be completed return -1.

Constraints

  • n == number of floors
  • 0 <= n <= 105
  • 1 <= windows[i] <= 5000
  • 1 <= h <= 5 * 105

Company Tags

[ ]