Today
Total
04-14 18:15
관리 메뉴

홍우진의 개발 일기장

[백준] 2303번: 숫자 게임 / 파이썬 본문

알고리즘/백준

[백준] 2303번: 숫자 게임 / 파이썬

홍우진 2025. 3. 6. 23:43
728x90
반응형

문제 링크


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

풀이 코드


n = int(input())
score = []

for _ in range(n):
    card = list(map(int,input().split()))
    top = 0

    for i in range(5):
        for j in range(i + 1, 5):
            for m in range(j + 1, 5):
                dap = (card[i] + card[j] + card[m])%10
                if dap >= top:
                    top = dap
                    
    score.append(top)

for i in range(n - 1, -1, -1):
    if score[i] == max(score):
        print(i + 1)
        break

코드 해석


 브루트포스와 삼중 for문을 써서 구한다.

번호가 큰 사람순으로 출력한다.

 

체감 난이도: ★★☆☆

728x90
반응형
Comments