https://www.acmicpc.net/problem/2798
: 카드 3장의 합,근데 이제 M을 넘지 않는.
N,M = map(int,input().split())
arr = list(map(int ,input().split()))
MaxAns = 0
for i in range(N):
for j in range(i+1,N):
for k in range(j+1,N):
total = arr[i] + arr[j] + arr[k]
if total <= M :
MaxAns = max(MaxAns,total)
print(MaxAns)
맨 처음 이 문제를 접했을 때 i,j,k 의 범위 설정에서 i+1, j+1 을 안해주어 틀렸었다.
그럼 i=0일 때, j=0 , k=0 이기 때문에 바로 나가리기 때문이다.
이번엔 실수없이 잘 풀었당!👍