Skip to content

Commit c656885

Browse files
committed
做了道题
1 parent 458f5f4 commit c656885

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

main.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,41 @@ def dfs(x, y, mode=1):
878878
accu.append([i,j])
879879
return accu
880880

881+
def minTime(self, skill: List[int], mana: List[int]) -> int:
882+
"""
883+
1 2 2 3 1 1
884+
2 4 4 6 2 2
885+
1 2 2 3 1 1
886+
"""
887+
n = len(skill)
888+
sum_mana = sum(mana)
889+
pre_mana = sum_mana - mana[-1]
890+
def compute(pre_sk, post_sk):
891+
if pre_sk <= post_sk:
892+
return 0
893+
else:
894+
pre_cost = pre_sk * sum_mana
895+
post_cost = post_sk * pre_mana
896+
if post_cost >= pre_cost:
897+
return 0
898+
else:
899+
return pre_cost - post_cost
900+
881901

902+
pre = -1
903+
accu = 0
904+
for sk in skill:
905+
if pre < 0:
906+
pre = sk
907+
continue
908+
else:
909+
bubble = compute(pre, sk)
910+
accu += max(pre * mana[0], bubble)
911+
pre = sk
912+
913+
accu += sum_mana * skill[-1]
914+
return accu
915+
def lenLongestFibSubseq(self, arr: List[int]) -> int:
882916

883917
# Your MovieRentingSystem object will be instantiated and called as such:
884918
# obj = MovieRentingSystem(n, entries)

test.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
from collections import Counter
22
from bisect import *
33

4-
a = [i for i in range(10)]
5-
def trig_split(idx1, idx2, values):
6-
return values[idx1:idx2 + 1], values[idx2:] + values[:idx1 + 1]
7-
8-
print(trig_split(7,9, a))
4+
a = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6}
5+
print(len(a))

0 commit comments

Comments
 (0)