fork download
  1. def check(y, req, stk, cst, bgt):
  2. tot = 0
  3. for i in range(len(req)):
  4. need = y * req[i]
  5. diff = max(0, need - stk[i])
  6. tot += diff * cst[i]
  7. return tot <= bgt
  8.  
  9. def solve(req, stk, cst, bgt):
  10. low = 0
  11. high = 10**12
  12. ans = 0
  13.  
  14. while low <= high:
  15. mid = (low + high) // 2
  16.  
  17. if check(mid, req, stk, cst, bgt):
  18. ans = mid
  19. low = mid + 1
  20. else:
  21. high = mid - 1
  22.  
  23. return ans
Success #stdin #stdout 0.08s 14172KB
stdin
Standard input is empty
stdout
Standard output is empty