해결된 질문
작성
·
355
0
import sys
input = sys.stdin.readline
K = int(input())
weights = list(map(int,input().split()))
possible = []
max = sum(weights)
def dfs(L,sum):
if L == K:
if 0 < sum <= max and sum not in possible:
possible.append(sum)
return
dfs(L+1,sum+weights[L])
dfs(L+1,sum-weights[L])
dfs(L+1,sum)
dfs(0,0)
print(max-len(possible))
답변 1
0