https://www.acmicpc.net/problem/2953
2953번: 나는 요리사다
"나는 요리사다"는 다섯 참가자들이 서로의 요리 실력을 뽐내는 티비 프로이다. 각 참가자는 자신있는 음식을 하나씩 만들어오고, 서로 다른 사람의 음식을 점수로 평가해준다. 점수는 1점부터 5
www.acmicpc.net
- python
import sys
score = {}
for i in range(5):
s = sum(list(map(int, sys.stdin.readline().split())))
score[i+1] = s
score = sorted(score.items(), key = lambda x : x[1])
for i in score[-1]:
print(i, end=" ")
- C++
#include<iostream>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
#include<sstream>
using namespace std;
int main(void) {
int temp;
int arr[5][4];
int Max = 0, maxIndex = 0;
for (int j = 0; j < 5; j++) {
int Sum = 0;
for (int i = 0; i < 4; i++) {
cin >> temp;
arr[j][i] = temp;
Sum += temp;
}
if (Sum > Max) {
Max = Sum;
maxIndex = j + 1;
}
}
cout << maxIndex << " " << Max;
}
'자기개발👨💻 > 코딩 알고리즘' 카테고리의 다른 글
[python] 프로그래머스 실패율 (0) | 2022.02.10 |
---|---|
[C++] 백준 5054 주차의 신 (0) | 2022.02.03 |
[python, C++] 백준 1292 쉽게 푸는 문제 (0) | 2022.02.03 |
[python, C++] 백준 2711 오타맨 고창영 (0) | 2022.02.03 |
[python, C++] 백준 2592 대표값 (0) | 2022.01.30 |
[python, C++] 백준 2577 숫자의 개수 (0) | 2022.01.30 |