SWEA 1940. 가랏! RC카!

JeanDeluge·2023년 2월 27일

SWEA

목록 보기
3/8

풀이과정

  1. 주어진 테스트케이스 중 해당 회차의 커맨드만 골라올 수 있도록 한다.
  2. 현재 거리, 현재 속도를 계속 확인하여 거리를 구한다.
  3. 초당 거리 = 속도(m/s) * 1초
  4. 만약 현재 속도보다 감속할 속도가 더 클 경우, 현재 속도를 0m/s 으로 조정한다.

통과

T = int(input())
# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다.
for test_case in range(1, T + 1):
    num_of_command = int(input())
    command_and_speed = []
    for command in range(0, num_of_command):
        command = list(map(int, input().split()))
        command_and_speed.append(command)
    distance = 0
    current_speed = 0
    for c in command_and_speed:
        current_command = c[0]
        if current_command == 1 :
            current_speed += c[1]
            distance += current_speed
        elif current_command == 2 :
            current_speed -= c[1]
            distance += current_speed
        else :
            distance += current_speed 
    print("#%d %d" % (test_case, distance))

오늘 풀이 시간

49분
현재로써는 레벨 2의 10문제만 목표는 1시간 안에 풀기, 이후에는 30분 안에 풀 수 있도록 하기

0개의 댓글