Re: [閒聊] 每日leetcode
看板Marginalman作者DJYOSHITAKA (franchouchouISBEST)時間1年前 (2024/06/18 22:28)推噓2(2推 0噓 5→)留言7則, 4人參與討論串380/1549 (看更多)
826. Most Profit Assigning Work
肥肥別的不懂
只懂得排序
def maxProfitAssignment(self, difficulty: List[int], profit: List[int],
worker: List[int]) -> int:
worker.sort()
difficulty, profit = zip(*sorted(zip(difficulty, profit)))
maximum_profit, idx, ans = 0, 0, 0
for d in worker:
while idx<len(difficulty) and d>=difficulty[idx]:
maximum_profit = max(maximum_profit, profit[idx])
idx += 1
ans += maximum_profit
return ans
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.79.54.128 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1718720901.A.101.html
推
06/18 22:33,
1年前
, 1F
06/18 22:33, 1F
→
06/18 22:34,
1年前
, 2F
06/18 22:34, 2F
推
06/18 22:50,
1年前
, 3F
06/18 22:50, 3F
→
06/18 22:55,
1年前
, 4F
06/18 22:55, 4F
→
06/18 22:57,
1年前
, 5F
06/18 22:57, 5F
→
06/18 22:58,
1年前
, 6F
06/18 22:58, 6F
→
06/18 23:05,
1年前
, 7F
06/18 23:05, 7F
討論串 (同標題文章)
完整討論串 (本文為第 380 之 1549 篇):