[Python] 백준 - 2480 - 주사위 세개

강주형·2022년 7월 29일
0

백준 알고리즘

목록 보기
2/14

https://www.acmicpc.net/problem/2480

# 2480

a, b, c = map(int, input().split())

if a == b == c:
    print(10000+1000*a)
elif a == b or a == c:
    print(1000+100*a)
elif b == c:
    print(1000+100*b)
else:
    print(max(a, b, c)*100)
2 2 2
12000
3 3 6
1300
6 2 5
600
2 6 5
600

내장 함수를 이용한 풀이

# 2480

from collections import Counter

dice = list(map(int, input().split()))

dice_unique = Counter(dice).most_common() # 갯수 많은 순으로 정렬

if len(dice_unique) == 3: # 다 다름
    print(sorted(dice_unique, reverse=True)[0][0]*100)
elif len(dice_unique) == 2: # 두 개 같음
    print(1000+dice_unique[0][0]*100)
else: # 모두 같음
    print(10000+dice_unique[0][0]*1000)
2 2 2
12000
3 3 6
1300
6 2 5
600
2 6 5
600

sorted()가 들어가버려서 시간복잡도가 늘어났으려나..?

profile
Statistics & Data Science

0개의 댓글