알고리즘/BOJ

백준 2953번 나는 요리사다

꾸준함. 2021. 5. 5. 20:58

문제 링크입니다: www.acmicpc.net/problem/2953

 

2953번: 나는 요리사다

"나는 요리사다"는 다섯 참가자들이 서로의 요리 실력을 뽐내는 티비 프로이다. 각 참가자는 자신있는 음식을 하나씩 만들어오고, 서로 다른 사람의 음식을 점수로 평가해준다. 점수는 1점부터 5

www.acmicpc.net

간단한 구현 문제였습니다.

 

#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;
}
view raw .cpp hosted with ❤ by GitHub

\

개발환경:Visual Studio 2017

 

지적, 조언, 질문 환영입니다! 댓글 남겨주세요~

반응형