문제 링크입니다: www.acmicpc.net/problem/15059
15059번: Hard choice
The first line contains three integers Ca, Ba and Pa (0 ≤ Ca, Ba, Pa ≤ 100), representing respectively the number of meals available for chicken, beef and pasta. The second line contains three integers Cr, Br and Pr (0 ≤ Cr, Br, Pr ≤ 100), indicati
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; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int Ca, Ba, Pa; | |
cin >> Ca >> Ba >> Pa; | |
int Cr, Br, Pr; | |
cin >> Cr >> Br >> Pr; | |
int result = (Ca - Cr < 0 ? abs(Ca - Cr) : 0) | |
+ (Ba - Br < 0 ? abs(Ba - Br) : 0) | |
+ (Pa - Pr < 0 ? abs(Pa - Pr) : 0); | |
cout << result << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 15128번 Congruent Numbers (0) | 2021.03.21 |
---|---|
백준 15080번 Every Second Counts (0) | 2021.03.19 |
백준 15051번 Máquina de café (0) | 2021.03.19 |
백준 15025번 Judging Moose (0) | 2021.03.19 |
백준 14935번 FA (0) | 2021.03.17 |