728x90
여렵지는 않았는데 temp.append(k[i]) 의 위치가 틀려서 오류가 났었다.
import sys
num = int(input())
k = list(map(int,sys.stdin.readline().strip().split(" ")))
temp = [ ]
for i in range(0,len(k)):
for j in range(0,len(temp)):
if k[i]+temp[j]>0:
temp.append(k[i]+temp[j])
if k[i]-temp[j]>0:
temp.append(k[i]-temp[j])
if -k[i]+temp[j]>0:
temp.append(-k[i]+temp[j])
temp.append(k[i])
temp = list(set(temp))
print(sum(k)-len(temp))
728x90
'🟢 알고리즘 문제 풀이 > Baekjoon' 카테고리의 다른 글
| [파이썬] 백준 1717 집합의 표현 (0) | 2023.04.08 |
|---|---|
| [파이썬] 백준 15686 치킨 배달 (0) | 2023.04.07 |
| [파이썬] 백준 1527 금만수의 개수 (0) | 2023.03.29 |
| [파이썬] 백준 2824 최대공약수 (0) | 2023.03.29 |
| [파이썬] 백준 2502 떡 먹는 호랑이 (0) | 2023.03.29 |