10819.차이를 최대로
- 내 풀이
- 문제를 바로 이해하지 못함
- 식이 배열 순서를 바꾼거라는게 아니라 배열 순서를 바꾼 뒤에 식을 진행했을때의 최댓값
from itertools import permutations
n = int(input())
nums = sorted(list(map(int, input().split())))
ans = 0
for perm in (permutations(nums, n)):
tmp = 0
for i in range(1, n):
tmp += abs(perm[i-1]-perm[i])
ans = max(ans, tmp)
print(ans)
'코딩테스트 > BOJ' 카테고리의 다른 글
| [백준][DP] 15486. 퇴사 2 (0) | 2024.10.08 |
|---|---|
| [백준][BFS/DFS][백트래킹][deepcopy] 15638.감시 (0) | 2024.10.01 |
| [백준][백트래킹] 16938.캠프 준비 (0) | 2024.10.01 |
| [백준][백트래킹] 1182. 부분수열의 합 (0) | 2024.10.01 |
| [백준][백트래킹] 2529. 부등호 (0) | 2024.10.01 |