Here is my solution for http://codeforces.me/problemset/problem/670/D1 ~~~~~ def ok(u, a, b, n, k): for i in xrange(n): if (u * a[i] — b[i] > 0): k -= u * a[i] — b[i] if k < 0: return False return k >= 0
L = lambda: map(int, raw_input().split()) n, k = L() a = L() b = L() l, r = 0, 2000000010 while l < r-1: g = (l+r) / 2 if ok(g, a, b, n, k): l = g else: r = g
print l ~~~~~ I dont know why it catch time limit exceeded on test 148. And then, I try g = l + (r-l+1) / 2, it is accepted? (g is midle in binary search), Im a newbie in python, and sorry for my bad in English