同步操作将从 编程语言算法集/Python 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
"""The following implementation assumes that the activitiesare already sorted according to their finish time""""""Prints a maximum set of activities that can be done by asingle person, one at a time"""# n --> Total number of activities# start[]--> An array that contains start time of all activities# finish[] --> An array that contains finish time of all activitiesdef print_max_activities(start: list[int], finish: list[int]) -> None:""">>> start = [1, 3, 0, 5, 8, 5]>>> finish = [2, 4, 6, 7, 9, 9]>>> print_max_activities(start, finish)The following activities are selected:0,1,3,4,"""n = len(finish)print("The following activities are selected:")# The first activity is always selectedi = 0print(i, end=",")# Consider rest of the activitiesfor j in range(n):# If this activity has start time greater than# or equal to the finish time of previously# selected activity, then select itif start[j] >= finish[i]:print(j, end=",")i = jif __name__ == "__main__":import doctestdoctest.testmod()start = [1, 3, 0, 5, 8, 5]finish = [2, 4, 6, 7, 9, 9]print_max_activities(start, finish)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。