1723. Find Minimum Time to Finish All Jobs
Содержание
class Solution:
def minimumTimeRequired(self, jobs: List[int], k: int) -> int:
def dfs(i):
nonlocal res
if i == len(jobs):
res = min(res, max(cnt))
return
for j in range(k):
if cnt[j] + jobs[i] >= res:
continue
cnt[j] += jobs[i]
dfs(i + 1)
cnt[j] -= jobs[i]
if cnt[j] == 0:
break
cnt = [0] * k
jobs.sort(reverse=True)
res = inf
dfs(0)
return res