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))
|
'Algorithm' 카테고리의 다른 글
[백준] 덩치 7568 브루트포스 Python (0) | 2019.10.12 |
---|---|
[백준] 분해합 2231 브루트포스 Python (0) | 2019.10.12 |
[백준] 셀프넘버 4673 Python (0) | 2019.10.12 |
[정렬] 삽입정렬 (0) | 2019.10.12 |
[정렬] 선택정렬 (Select Sort) (0) | 2019.10.11 |