Problem with python??

Revision en1, by duongtnhat, 2016-05-06 08:43:42

Here is my solution for http://mirror.codeforces.com/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

Tags coding, python 2, #contest

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English duongtnhat 2016-05-06 08:46:40 504
en1 English duongtnhat 2016-05-06 08:43:42 742 Initial revision (published)