This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import math
def solve():
n, m = map(int, input().split())
list_1 = list(map(int, input().split()))
list_2 = list(map(int, input().split()))
curr_max = 0
for i in range(n):
curr_max = max(curr_max, max(list_2[i], list_1[i]))
l, r = 0, m * n * curr_max
while l + 1 < r:
mid = (l + r) // 2
total = 0
for i in range(n):
if list_1[i] > list_2[i]:
if m * list_1[i] < mid:
total += m
total += math.ceil((mid - m * list_1[i]) / list_2[i])
else:
total += math.ceil(mid / list_1[i])
else:
total += math.ceil(mid / list_2[i])
if total > m * n:
r = mid
else:
l = mid
print(l)
solve()
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |