import sys
sys.stdin = open("input.txt", "rt")
n, k = map(int, input().split())
a = list(map(int, input().split()))
res = set()
for i in range(n):
for j in range(i+1):
for m in range(j+1):
res.add(a[i]+ a[j]+ a[m]) # res 에 집어 넣음
res = list(res)
res.sort(reverse = True)
print(res)
print(res[k-1])
결과값이
[13, 15, 34, 23, 45, 65, 33, 11, 26, 42] # 입력 리스트 a의 값 [195, 175, 172, 164, 163, 156, 155, 153, 152, 149, 145, 144, 143, 141, 140, 136, 135, 133, 132, 131, 130, 129, 126, 125, 124, 123, 122, 121, 120, 118, 117, 116, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 45, 43, 41, 39, 37, 35, 33] # res = list(res) 172
이렇게 나옵니다...
a[i]+ a[j]+ a[m]으로 계산된 값을 보면 172가 정답이긴 한데..선생님의 코드랑 똑같고 인풋도 똑같은데 어쩨서 아웃풋이 다른지 모르겠습니다.
ps- 10 13 # n, k = map(int, input().split()) 코드에 해당 하는 이 줄에서
k = 13일 경우 143이 출력됩니다.
이러한 경우가 아닌가 문의드립니다!
감사합니다.