본문 바로가기
Tech/Coding

by redcubes 2025. 5. 20.

코드

import io
inp=io.BufferedReader(io.FileIO(0),1<<18).readline
res=[]
while True:
    o,w=map(int,inp().split())
    if o==w==0:break
    while w>=0:
        c,i=inp().split()
        if c==b'#':break
        else:
            w+=(((c==b"E")*-2)+1)*int(i)
    if (o/2)<w<(o*2):
        res.append(":-)")
    elif w<=0:
        res.append("RIP")
    else:
        res.append(":-(")
        
print('\n'.join(f"{k} {j}" for k,j in enumerate(res,start=1)))