[Python] 펫 - 백준 1362

찐새·2022년 6월 9일
0

코딩테스트

목록 보기
11/53
post-thumbnail

펫 - 백준 1362

풀이

from sys import stdin
input = stdin.readline

scene_num = 0
state = [":-)", ":-(", "RIP"]

while (n:=input().split()) != ["0", "0"]:
    o, w = map(int, n)
    while (m:=input().split()) != ["#", "0"]:
        if w > 0:
            if m[0] == "F":
                w += int(m[1])
            else:
                w -= int(m[1])
                
    scene_num += 1
    if (o * 0.5) < w < (o * 2):
        print(scene_num, state[0])
    elif w <= 0:
        print(scene_num, state[2])
    else:
        print(scene_num, state[1])

문제의 설명대로 진행했다. 펫에 대한 행동은 w0보다 클 때만 적용했다.

profile
프론트엔드 개발자가 되고 싶다

0개의 댓글