将A = [[1,2], [3,4], [1,3], [5,7]]输入一下算法并形成完整代码,def maxAssignment(A): A = sorted(A,key=lambda x:x[1]) current_day = 1 count = 0 for duration,deadline in A: if current_day + duration -1 <=deadline: count +=1 current_day += duration return count
时间: 2023-04-09 07:03:33 浏览: 162
这是一个算法问题,我可以回答。以下是完整代码:
def maxAssignment(A):
A = sorted(A,key=lambda x:x[1])
current_day = 1
count = 0
for duration,deadline in A:
if current_day + duration -1 <=deadline:
count +=1
current_day = current_day + duration
return count
阅读全文