[Baekjoon] 10819 차이를 최대로 python

sorzzzzy·2021년 8월 4일
0

Baekjoon Algorithm

목록 보기
24/46
post-thumbnail

🏷 문제


💡 코드

from itertools import permutations

n = int(input())
num_list = list(map(int, input().split()))

res_list = list(set(permutations(num_list, n)))

res = -1e9

for i in res_list:
    tmp = 0
    tmp_list = list(i)
    for j in range(len(tmp_list)-1):
        tmp += abs(tmp_list[j]-tmp_list[j+1])
    res = max(res, tmp)
print(res)

🔑

profile
Backend Developer

0개의 댓글