-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode4.py
More file actions
38 lines (31 loc) · 1.16 KB
/
code4.py
File metadata and controls
38 lines (31 loc) · 1.16 KB
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
34
35
36
37
38
# 출처: https://school.programmers.co.kr/learn/courses/30/lessons/250137
# [PCCP 기출문제] 1번 / 붕대 감기
def isMaxHeal(current, max):
if current > max:
current = max
return current
def solution(bandage, health, attacks):
successive_score = 0
current_health = health
idx = 0
for time in range(0, attacks[-1][0] + 1):
successive_score += 1
attack_time = [i[0] for i in attacks]
attack_degree = [i[1] for i in attacks]
if time in attack_time:
current_health -= attack_degree[idx]
current_health = isMaxHeal(current_health, health)
idx += 1
successive_score = 0
else:
if current_health < health:
current_health += bandage[1]
current_health = isMaxHeal(current_health, health)
if successive_score == bandage[0]:
current_health += bandage[2]
current_health = isMaxHeal(current_health, health)
successive_score = 0
if current_health <= 0:
current_health = -1
break;
return current_health