[SW Expert Academy, SWEA 1940] 가랏! RC카! (python)
Problem Solving/SWEA

[SW Expert Academy, SWEA 1940] 가랏! RC카! (python)

728x90

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5PjMgaALgDFAUq&categoryId=AV5PjMgaALgDFAUq&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=2&pageSize=10&pageIndex=3

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


※ SW Expert 아카데미의 문제를 무단 복제하는 것을 금지합니다.

728x90

T = int(input())

for test_case in range(1, T + 1):
    n = int(input())
    spd = 0 # 속도
    dis = 0 # 거리
    
    for i in range(n):
        c = list(map(int, input().split())) # command

        if (c[0] == 1): # 가속
            spd += c[1]
        elif (c[0] == 2): # 감속
            spd -= c[1]
            if (spd < 0): # 현재 속도보다 감속할 속도가 더 클 경우,
                spd = 0 # 속도는 0 m/s

        dis += spd
    
    print("#{} {}".format(test_case, dis))

문제 설명이 굉장히 불친절한 것 같은 느낌...

내 이해력의 문제일 수도 있지만, 문제를 어떻게 풀어야 하는지보다 문제 자체를 이해하는데 더 시간이 걸렸다..

728x90