PCCP 기출문제] 1번 / 붕대 감기
조회수 845회
def solution(bandage, health, attacks):
count_time = 0
attacks_time = 0
bandage_time = 0
base_health = health
while True:
count_time+=1
if attacks[attacks_time][0] == count_time:
health -= attacks[attacks_time][1]
bandage_time = 0
if health <= 0:
break
attacks_time +=1
if attacks_time == len(attacks):
break
else:
bandage_time +=1
if bandage_time == bandage[2]:
health = health + bandage[1]+bandage[2]
if health > base_health:
health = base_health
bandage_time = 0
else:
health += bandage[1]
if health > base_health:
health = base_health
if health <= 0:
return -1
else:
return health
제출 후 테스트 14번이 실패합니다. 어디가 오류인지 찾아주세요ㅠㅠ
댓글 입력