Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
import numpy as np
i8 = np.int64
i4 = np.int32
def solve(A,F,K):
  min_ = 0
  max_ = 10**12
  while min_ < max_:
    mid = (min_ + max_) // 2
    count = A - mid // F
    sum_ = count[count > 0].sum()
    if sum_ <= K:
      max_ = mid
    else:
      min_ = mid + 1
def main():
  stdin = open('/dev/stdin','rb')
  pin = np.fromstring(stdin.read(),i8,sep=' ')
  N, K = pin[:2]
  A = pin[2: N + 2]
  F = pin[N+2: 2*N+2]
  A = np.sort(A)[::-1]
  F.sort()
  res = solve(A,F,K)
  print(res)
if __name__ == '__main__':
  main()

n,k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))
a.sort()
f.sort(reverse = True)

def is_ok(t):
  cost = 0
  for aa,ff in zip(a,f):
    temp = t // ff
    if temp >= aa:
      contninue
    cost += aa - temp
  if cost <= k:
    return True
  return False
left = 0
right = a[-1]*f[0]
while left < right:
  mid = (left + right) // 2
  if is_ok(mid):
    right = mid
  else:
    left = mid + 1
print(left)

n,k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))
a.sort()
f.sort(reverse = True)

def is_ok(t):
  cost = 0
  for aa,ff in zip(a,f):
    temp = t // ff
    if temp >= aa:
      contninue
    cost += aa - temp
    if cost > k:
      return False
  return True
left = 0
right = a[-1]*f[0]+1
while left < right:
  mid = (left + right) // 2
  if is_ok(mid):
    right = mid
  else:
    left = mid + 1
print(left)


import numpy as np
i8 = np.int64
i4 = np.int32


def solve(A, F, K):
    min_ = 0
    max_ = 10 ** 12
    while min_ < max_:
        mid = (min_ + max_) // 2
        count = A - mid // F
        sum_ = count[count > 0].sum()
        if sum_ <= K:
            max_ = mid
        else:
            min_ = mid + 1
    return min_

def main():
    stdin = open('/dev/stdin', 'rb')
    pin = np.fromstring(stdin.read(), i8, sep=' ')
    N, K = pin[:2]
    A = pin[2: N + 2]
    F = pin[N + 2: 2 * N + 2]
    A = np.sort(A)[::-1]
    F.sort()
    ans = solve(A, F, K)
    print(ans)

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted