-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lv.1 붕대감기.py
33 lines (30 loc) · 965 Bytes
/
Lv.1 붕대감기.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
31
32
33
def isMaxHealth(health, max_health):
if health>max_health:
return max_health
else:
return health
def heal(health, bandage, bandage_count, max_health):
health+=bandage[1]
bandage_count+=1
if(bandage_count==bandage[0]):
health+=bandage[2]
bandage_count=0
health=isMaxHealth(health, max_health)
return health, bandage_count
def solution(bandage, health, attacks):
attacks_num=len(attacks)
last_attacks_time = attacks[attacks_num-1][0]
max_health=health
attacks_count=0
bandage_count=0
for i in range(1,last_attacks_time+1):
if attacks[attacks_count][0] == i:
health-=attacks[attacks_count][1]
bandage_count=0 //추가
if health <=0:
health = -1
break
attacks_count+=1
else:
health, bandage_count = heal(health, bandage, bandage_count, max_health)
return health