fork(1) download
  1. import sys
  2.  
  3. sys.stdin = open('plants.in', 'r')
  4. rints = lambda: [int(x) for x in sys.stdin.readline().split()]
  5. n, a, b, ans = int(input()), rints(), rints(), 0
  6.  
  7. for i in range(1, n):
  8. a[i] += ans * b[i]
  9. if b[i - 1] >= b[i]:
  10. if a[i - 1] > a[i]:
  11. ans = -1
  12. break
  13. else:
  14. be, en, cur = 0, 10 ** 9, float('inf')
  15. while be <= en:
  16. md = (be + en) >> 1
  17. if a[i - 1] + md * b[i - 1] <= a[i] + md * b[i]:
  18. en, cur = md - 1, md
  19. else:
  20. be = md + 1
  21. ans = max(ans, cur)
  22. print(ans)
  23.  
Runtime error #stdin #stdout #stderr 0.01s 7284KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 3, in <module>
IOError: [Errno 2] No such file or directory: 'plants.in'