Re: [閒聊] 每日leetcode已回收

看板Marginalman作者 (franchouchouISBEST)時間1年前 (2024/06/15 09:59), 編輯推噓2(202)
留言4則, 3人參與, 1年前最新討論串362/1548 (看更多)
502. IPO 維持maxheap內只有符合capital條件的profits即可 def findMaximizedCapital(self, k: int, w: int, profits: List[int], capital: List[int]) -> int: l = sorted([(cap, pro) for cap, pro in zip(capital, profits)]) h = [] cur_i, n = 0, len(profits) for i in range(k): while cur_i<n and l[cur_i][0] <= w: heappush(h, -l[cur_i][1]) cur_i += 1 if len(h)>0: cur_profit = heappop(h) w -= cur_profit return w -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.228.146.144 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1718416785.A.CA6.html

06/15 10:00, 1年前 , 1F
wwwww
06/15 10:00, 1F

06/15 10:00, 1年前 , 2F
別卷了
06/15 10:00, 2F

06/15 10:01, 1年前 , 3F
大師 幫內推
06/15 10:01, 3F

06/15 10:08, 1年前 , 4F
誰周末還刷題的
06/15 10:08, 4F
文章代碼(AID): #1cRFMHoc (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1cRFMHoc (Marginalman)