I.sly()/10기 심화 - 프로그래밍

백준 2798번 블랙잭

mameul 2024. 10. 8. 22:12
728x90

N, M = map(int, input().split())

card = [int(x) for x in input().split()]

max = 0

for i in range(len(card)):
    for j in range(i+1,len(card)):
        for k in range(j+1,len(card)):
            sum = card[i] + card[j] + card[k]
            if max<sum<=M:
                max = sum

print(max)