Python/백준 (BOJ)

[BOJ][B2]주사위 네개- 2484

ㅋㅋ! 2025. 8. 26. 13:00

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

문제 전문은 링크 참조

문제가공

중복제거 눈 개수 =  예) 주사위 4 4 4 4 의 중복제거 눈 개수 = 1, 주사위가 2 2 3 4 의 중복제거 눈 개수 = 3

  1. 주사위 같은 수 네개 (중복제거 눈 개수 : 1) = 50,000 + (주사위 눈 * 5,000)
  2. 주사위 같은 수 세개 (중복제거 눈 개수 : 2) = 10,000 + (같은 눈 * 1,000)
  3. 즈사위 같은 눈 두개씩 두쌍 (중복제거 눈 개수 : 2) = 2,000 + (같은 눈 *500) + (같은 눈 *500)
  4. 주사위 같은 눈 두개 (중복제거 눈 개수 : 3) = 1,000+ (같은 눈*100)
  5. 모두 다른 눈 (중복제거 눈 개수 : 4) = 가장 큰 눈 * 100

코드작성

import collections
answer = [] 
for _ in range(int(input())):
    arr = sorted(list(map(int,input().split())))
    length = len(set(arr))
    if length ==1:
        answer.append(50000+arr[0]*5000)
    elif length ==4:
        answer.append(arr[-1]*100)
    elif length ==2:
        s = list(set(arr))
        if arr[0]==arr[1] and arr[2]==arr[3]:
            answer.append(2000+s[0]*500+s[1]*500)
        else:
            if arr[0]!=arr[1]:
                answer.append(10000+arr[-1]*1000)
            else:
                answer.append(10000+arr[0]*1000)
    else :
        dic = collections.Counter(arr)
        answer.append(1000+[i for i in dic if dic[i]==2][0]*100)
print(max(answer))

 

'Python > 백준 (BOJ)' 카테고리의 다른 글

[BOJ][B2]연속구간 - 2495  (0) 2025.08.28
[BOJ][B2]큰 수 계산 - 2408  (0) 2025.08.27
[BOJ][B2]도비의 영어 공부 - 2386  (0) 2025.08.25
[BOJ][B2]시그마 - 2355  (2) 2025.08.24
[BOJ][B2]이어 쓰기 3- 2154  (0) 2025.08.23