4
3 3 3 3
3 3 6 3
2 2 6 6
6 2 1 5
# 상금 계산 함수
def CalculateReward(diceList):
result = 0
if len(set(diceList)) == 1: # 모두 같은 눈
result = 50000 + diceList[0]*5000
elif len(set(diceList)) == 2: # 같은 눈 3개 or 같은 눈 2개 2쌍
if diceList[1] == diceList[2]:
result = 10000 + diceList[1]*1000
else:
result = 2000 + diceList[1]*500 + diceList[2]*500
elif len(set(diceList)) == 3: # 같은 눈 2개 1쌍
if diceList[0] == diceList[1]:
result = 1000 + diceList[0]*100
elif diceList[1] == diceList[2]:
result = 1000 + diceList[1]*100
else:
result = 1000 + diceList[2]*100
else: # 모두 다른 경우
result = diceList[3]*100
return result
numberOfPerson = int(input())
reward = []
for i in range(numberOfPerson):
diceList = sorted(list(map(int, input().split())))
reward.append(CalculateReward(diceList))
print(max(reward))
Set을 이용한 중복을 제거하는 것이 핵심인 문제이다. 주어진 조건에 따른 정확하고 간단한 예외처리를 할 수 있는지 물어보는 문제인 것 같다.
안녕하세요! 풀이 너무 깔끔하십니다. 배우고 갑니다 ^^