Skip to content

Commit e72d250

Browse files
committed
[BOJ] 2798 블랙잭 (B2)
1 parent cf69aee commit e72d250

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

심수연/2주차/260109.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# https://www.acmicpc.net/problem/2798
2+
3+
import sys
4+
input = sys.stdin.readline
5+
6+
N, M = map(int, input().split())
7+
cards = list(map(int, input().split()))
8+
9+
max_value = 0
10+
# 3장 -> i, j, k 3중 for문
11+
for i in range(N):
12+
for j in range(i+1, N):
13+
for k in range(j+1, N):
14+
sum = cards[i] + cards[j] + cards[k]
15+
if sum <= M and sum > max_value: # M보다 작거나 같고, 최댓값보다 크다면
16+
max_value = sum # 최댓값 갱신
17+
18+
print(max_value)

0 commit comments

Comments
 (0)