https://www.acmicpc.net/problem/2798
2798번: 블랙잭
첫째 줄에 카드의 개수 N(3 ≤ N ≤ 100)과 M(10 ≤ M ≤ 300,000)이 주어진다. 둘째 줄에는 카드에 쓰여 있는 수가 주어지며, 이 값은 100,000을 넘지 않는 양의 정수이다. 합이 M을 넘지 않는 카드 3장
www.acmicpc.net
Python
n, m = list(map(int, input().split(" ")))
numbers = list(map(int, input().split(" ")))
result = 0
length = len(numbers)
count = 0
for i in range(0, length):
for j in range(i + 1, length):
for k in range(j + 1, length):
sum_value = numbers[i] + numbers[j] + numbers[k]
if sum_value <= m:
result = max(result, sum_value)
print(result)
'알고리즘 > 백준' 카테고리의 다른 글
[Python] 백준 2920번 - 음계 (0) | 2021.07.21 |
---|---|
[Python] 백준 5397번 - 키로거 (0) | 2021.07.21 |
[Python] 백준 10996번 - 별 찍기 - 21 (0) | 2020.06.11 |
[Python] 백준 2446번 - 별 찍기 - 9 (0) | 2020.06.09 |
[Python] 백준 2523번 - 별 찍기 - 13 (0) | 2020.06.09 |
댓글