문제 링크입니다: www.acmicpc.net/problem/2953
2953번: 나는 요리사다
"나는 요리사다"는 다섯 참가자들이 서로의 요리 실력을 뽐내는 티비 프로이다. 각 참가자는 자신있는 음식을 하나씩 만들어오고, 서로 다른 사람의 음식을 점수로 평가해준다. 점수는 1점부터 5
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains 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 = 5; | |
typedef struct | |
{ | |
int score; | |
int contestant; | |
} Cook; | |
bool cmp(Cook a, Cook b) | |
{ | |
return a.score > b.score; | |
} | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
Cook cooks[MAX]; | |
for (int i = 1; i <= MAX; i++) | |
{ | |
int sum = 0; | |
for (int j = 0; j < 4; j++) | |
{ | |
int score; | |
cin >> score; | |
sum += score; | |
} | |
cooks[i - 1] = { sum, i }; | |
} | |
sort(cooks, cooks + MAX, cmp); | |
cout << cooks[0].contestant << " " << cooks[0].score << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 2965번 캥거루 세마리 (0) | 2021.05.07 |
---|---|
백준 2959번 거북이 (0) | 2021.05.07 |
백준 21611번 마법사 상어와 블리자드 (0) | 2021.05.03 |
백준 20058번 마법사 상어와 파이어스톰 (2) | 2021.05.03 |
백준 21638번 SMS from MCHS (0) | 2021.05.02 |