Algorithm
[백준] 블랙잭 2798 브루트포스(Brute Force) Python
hackyu
2019. 10. 12. 17:36
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import itertools
N, M = map(int, input().strip().split())
lists = list(map(int, input().strip().split()))
chk = 0
lists_combinations = itertools.combinations(lists,3)
combisums = []
for i in lists_combinations:
if M == sum(list(i)): # 만약 같은 값이 나오면 최대이기에 출력하고 종료
print(sum(list(i)))
chk = 1
break
if sum(list(i)) <= M:
if chk == 0:
print(max(combisums))
|
|