https://www.acmicpc.net/problem/2798
2798번: 블랙잭
첫째 줄에 카드의 개수 N(3 ≤ N ≤ 100)과 M(10 ≤ M ≤ 300,000)이 주어진다. 둘째 줄에는 카드에 쓰여 있는 수가 주어지며, 이 값은 100,000을 넘지 않는 양의 정수이다. 합이 M을 넘지 않는 카드 3장
www.acmicpc.net
from itertools import combinations
a,b = map(int,input().split())
c = list(map(int,input().split()))
arr = []
for i in combinations(c,3):
arr.append(sum(i))
answer = 0
for i in arr:
if i <= b:
if answer < i:
answer = i
print(answer)
'알고리즘' 카테고리의 다른 글
백준)Hello World! (0) | 2023.02.20 |
---|---|
백준)분해합 (0) | 2023.02.20 |
프로그래머스)문자열 나누기 (0) | 2023.02.19 |
백준)영역구하기 (0) | 2023.02.18 |
프로그래머스)2개 이하로 다른 비트 (0) | 2023.02.17 |