Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng == 1: break
  m = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    while a*f > m:
      a -= 1
      now_cost += 1
  if now_cost <= K:
    ok = m
  else:
    ng = m
    
print(ok)

Fixed submission:
N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng == 1: break
  m = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    now_cost += max(a-(m//f), 0)
  if now_cost <= K:
    ok = m
  else:
    ng = m
    
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng < 2: break
  k = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    while a*f > k:
      a -= 1
      now_cost += 1
    if now_cost > K: break
  if now_cost > K:
    ng = k
  else:
    ok = k
    
print(ok)


Fixed submission:
N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng == 1: break
  m = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    now_cost += max(a-(m//f), 0)
  if now_cost <= K:
    ok = m
  else:
    ng = m
    
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng < 2: break
  k = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    while a*f > k:
      a -= 1
      now_cost += 1
    if now_cost > K: break
  if now_cost > K:
    ng = k
  else:
    ok = k
    
print(ok)


Fixed submission:
N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng == 1: break
  m = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    now_cost += max(a-(m//f), 0)
  if now_cost <= K:
    ok = m
  else:
    ng = m
    
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))

def argmax(x):
  return max(enumerate(x), key=lambda x:x[1])[0]

while K > 0:
  now_costs = [a*f for a, f in zip(A, F)]
  if max(now_costs) < 1: break
  A[(argmax(now_costs))] -= 1
  K -= 1
print(max([a*f for a, f in zip(A, F)]))

Fixed submission:
N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng == 1: break
  m = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    now_cost += max(a-(m//f), 0)
  if now_cost <= K:
    ok = m
  else:
    ng = m
    
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))

def argmax(vec):
  max_i = set()
  max_v = 0
  for i, v in enumerate(vec):
    if v > max_v:
      max_v = v
      max_i = {i}
    elif v == max_v:
      max_i.add(i)
  return max_i

while K > 0:
  now_costs = [a*f for a, f in zip(A, F)]
  if max(now_costs) < 1: break
  bottleneck = argmax(now_costs)
  if len(bottleneck) > K: break
  for b in bottleneck:
    A[b] -= 1
  K -= len(bottleneck)
print(max([a*f for a, f in zip(A, F)]))

Fixed submission:
N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng == 1: break
  m = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    now_cost += max(a-(m//f), 0)
  if now_cost <= K:
    ok = m
  else:
    ng = m
    
print(ok)