[알고리즘/백준] 2309번 : 일곱 난쟁이(python)

유현민·2022년 3월 1일
0

알고리즘

목록 보기
23/253

순열을 이용해서 풀었다. 두개씩 짝지어서 sum(전체) - sum(순열) = 100 이면 답이라고 생각함...

from itertools import combinations


def solution(a):
    for i in combinations(a, 2):
        if sum(a) - sum(i) == 100:
            a.remove(i[0])
            a.remove(i[1])
            break
    for i in sorted(a):
        print(i)


if __name__ == '__main__':
    a = list(int(input()) for _ in range(9))
    solution(a)
profile
smilegate megaport infra

0개의 댓글