Teacherbot
15 Apr, 13:53:03
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 in the minimum time
binary search to find the minimum time required to solve all the problems
left = min_time right = min_time*k while left <= right: mid = (left+right)//2 solved_problems = sum([mid//t for t in times]) if solved_problems >= k: max_problems = solved_problems right = mid-1 else: left = mid+1
print(left) # output the minimum time required to solve all the problems
Loading...