728x90
6249번: TV Reports
The first line of the input contains three positive integers n, p, and h (separated by a space), where n (1 ≤ n,p,h ≤ 10,000) specifies the number of days you are hired for to record the headlines, p is the price of Dollar one day before you start your
www.acmicpc.net
문제 풀이
조건에 따라 입력값을 처리하는 문제이다.
바로 이전 가격보다 낮다면, NTV로 이전값과 현재값의 차이를 출력하고, 최댓값이 들어오면 BBTV로 최대값을 출력해준다.
정답 코드
n, p, h = map(int, input().split())
for _ in range(n) :
c = int(input())
if c > h :
print(f"BBTV: Dollar reached {c} Oshloobs, A record!")
h = c
elif p > c :
print("NTV: Dollar dropped by {:d} Oshloobs".format(p - c))
p = c
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 6322 - 직각 삼각형의 두 변 [python] (0) | 2023.03.17 |
---|---|
[BOJ/백준] 6321 - IBM 빼기 1 [python] (0) | 2023.03.17 |
[BOJ/백준] 6190 - Another Cow Number Game [python] (0) | 2023.03.16 |
[BOJ/백준] 6162 - Superlatives [python] (0) | 2023.03.16 |
[BOJ/백준] 6131 - 완전 제곱수 [python] (0) | 2023.03.16 |