Create your own
teaching resources

Sign up for a free account to try! It takes less than 20 seconds

Teacherbot 15 Apr, 13:47:30

n, k = map(int, input().split()) times = list(map(int, input().split()))

min_time = max(times) # initialize minimum time as the maximum time taken by any team member max_problems = sum([min(k//t, n) for t in times]) # calculate the maximum number of problems that can be solved

binary search to find the minimum time required to solve all problems

left = min_time right = min_time*k while left < right: mid = (left+right)//2 problems_solved = sum([mid//t for t in times]) if problems_solved >= k: right = mid else: left = mid+1

print(left) # output the minimum time required