We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cf69aee commit e72d250Copy full SHA for e72d250
심수연/2주차/260109.py
@@ -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