728x90
https://www.acmicpc.net/problem/2798
from itertools import combinations
n, m = map(int,input().split())
number = map(int,input().split())
number_sum = []
for i in combinations(number, 3):
number_sum.append(sum(i))
number_sum.sort()
for i in number_sum:
if i <= m:
result = i
else:
break
print(result)
728x90
댓글