728x90
4635번: Speed Limit
The input consists of one or more data sets. Each set starts with a line containing an integer n, 1 ≤ n ≤ 10, followed by n pairs of values, one pair per line. The first value in a pair, s, is the speed in miles per hour and the second value, t, is t
www.acmicpc.net
문제 풀이
단순한 사칙연산 문제이다. 다만, 입력값으로 주어지는 t가 누적값이므로 주의하자.
정답 코드
while True :
n = int(input())
if n == -1 : break
ans, last = 0, 0
for _ in range(n) :
s, t = map(int, input().split())
ans += s * (t - last)
last = t
print(ans, "miles")
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 4758 - Filling Out the Team [python] (0) | 2023.03.10 |
---|---|
[BOJ/백준] 4740 - 거울, 오! 거울 [python] (0) | 2023.03.10 |
[BOJ/백준] 4562 - No Brainer [python] (0) | 2023.03.10 |
[프로그래머스] 이진 변환 반복하기 [python] (0) | 2023.03.10 |
[BOJ/백준] 4435 - 중간계 전쟁 [python] (0) | 2023.03.08 |