백준 알고리즘

[백준(BOJ) - Python] 2798번 <블랙잭>

멜론이즈 2022. 2. 21. 21:01

📄문제


🔍나의 코드

n, m = map(int,input().split())
cards = list(map(int,input().split()))
result = 0


for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if cards[i] + cards[j] + cards[k] > m:
                continue
            else:
                result = max(result, cards[i] + cards[j] + cards[k])
print(result)

문제 출처 : https://www.acmicpc.net/problem/2798