Python(알고리즘,문제풀이)/BOJ(Bronze II)

백준 / 2798번 / 블랙잭 / Python

박혀노 2023. 12. 5. 12:13
728x90

📚문제

출처 : 백준 2798번(https://www.acmicpc.net/problem/2798)


📝풀이

# 2798번 블랙잭
n,m = map(int,input().split())
num_list = list(map(int,input().split()))
result = []
for i in num_list[:-2]:
    for j in num_list[1:-1]:
        for k in num_list[2:]:
            if i+j+k <= m and (i!=j and j!=k and i!=k):
                result.append(i+j+k)
print(max(set(result)))

 

728x90