본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 10471번 공간을 만들어 봅시다

by 현장 2023. 5. 20.

-Code

w, p = map(int, input().split())
res = []
partition = [0] + list(map(int, input().split())) + [w]


for i in range(len(partition) - 1):
    for j in range(i + 1, len(partition)):
        res.append(partition[j] - partition[i])

print(*sorted(set(res)))