PCCP 기출문제] 1번 / 붕대 감기

조회수 486회
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번이 실패합니다. 어디가 오류인지 찾아주세요ㅠㅠ

1 답변

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)