문제 링크입니다: https://www.acmicpc.net/problem/6249
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
간단한 구현 문제였습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int n, p, h; | |
cin >> n >> p >> h; | |
for (int i = 0; i < n; i++) | |
{ | |
int dollar; | |
cin >> dollar; | |
if (dollar > h) | |
{ | |
printf("BBTV: Dollar reached %d Oshloobs, A record!\n", dollar); | |
h = dollar; | |
p = dollar; | |
continue; | |
} | |
if (dollar < p) | |
{ | |
printf("NTV: Dollar dropped by %d Oshloobs\n", p - dollar); | |
} | |
p = dollar; | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 6378번 디지털 루트 (0) | 2021.06.01 |
---|---|
BOJ 6322번 직각 삼각형의 두 변 (0) | 2021.05.31 |
백준 6190번 Another Cow Number Game (0) | 2021.05.29 |
백준 6162번 Superlatives (0) | 2021.05.29 |
백준 6139번 Speed Reading (0) | 2021.05.29 |