fork download
  1. def check(mid, arr, max_moves):
  2. count = 0
  3. for num in arr:
  4. if num % mid == 0:
  5. count += num // mid
  6. else:
  7. count += num // mid + 1
  8.  
  9. return max_moves >= count
  10.  
  11. def solve(arr, max_moves):
  12. low = 1
  13. high = max(arr)
  14. ans = -1
  15.  
  16. while low <= high:
  17. mid = (low + high) // 2
  18.  
  19. if check(mid, arr, max_moves):
  20. ans = mid
  21. high = mid - 1
  22. else:
  23. low = mid + 1
  24.  
  25. return ans
Success #stdin #stdout 0.07s 14184KB
stdin
Standard input is empty
stdout
Standard output is empty