-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem2238.py
30 lines (26 loc) · 994 Bytes
/
problem2238.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# <---coding: utf-8--->
# @Time: 2022/10/10/12:08
# @Author = posiondy
# @Email: 1547590574@qq.com
# @Software: PyCharm
from typing import List
class Solution:
def minNumberOfHours(self, initialEnergy: int, initialExperience: int, energy: List[int], experience: List[int]) -> int:
length = len(energy)
n, hours = 0, 0
while n < length:
if initialExperience <= experience[n]:
temp = experience[n]-initialExperience + 1
initialExperience += temp
hours += temp
if initialEnergy <= energy[n]:
temp = energy[n] - initialEnergy + 1
initialEnergy += temp
hours += temp
if initialExperience > experience[n] and initialEnergy > energy[n]:
initialExperience += experience[n]
initialEnergy -= energy[n]
n += 1
return hours
s = Solution()
print(s.minNumberOfHours(5,3,[1,4,3,2],[2,6,3,1]))