문제 링크입니다: www.acmicpc.net/problem/2455
2455번: 지능형 기차
최근에 개발된 지능형 기차가 1번역(출발역)부터 4번역(종착역)까지 4개의 정차역이 있는 노선에서 운행되고 있다. 이 기차에는 타거나 내리는 사람 수를 자동으로 인식할 수 있는 장치가 있다.
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> | |
#include <algorithm> | |
using namespace std; | |
const int MAX = 4; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int sum = 0; | |
int result = 0; | |
for (int i = 0; i < MAX; i++) | |
{ | |
int descend, ascend; | |
cin >> descend >> ascend; | |
sum += (ascend - descend); | |
result = max(result, sum); | |
} | |
cout << result << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
[KOI 초등부] 백준 2490번 윷놀이 (0) | 2021.04.21 |
---|---|
[KOI 중등부] 백준 2460번 지능형 기차 2 (0) | 2021.04.18 |
백준 13718번 Tavan (2) | 2021.04.17 |
백준 2446번 별 찍기 - 9 (0) | 2021.04.15 |
백준 2445번 별 찍기 - 8 (0) | 2021.04.15 |