λ¬Έμ
λ°±μ€ μ¨λΌμΈ μ μ§ - 10819λ²
νμ΄ κ³Όμ
μμ΄
μ μμ±ν΄μ λͺ¨λ κ°λ₯ν κ²½μ°μ μλ€μ λ§λ€μ΄λ³΄λ μμ νμ
λ¬Έμ μ
λλ€.
μ΄νμ λ¬Έμ μμ μ μλ μμμ μ΄μ©ν΄μ κ°μ κ³μ°νκ³ μ΄ μ€ μ΅λκ°μ λ΅μΌλ‘ λ°ννλ©΄ λ©λλ€.
μ½λ
import sys
from itertools import permutations
def solution():
max_value = 0
for perm in permutations(numbers):
acc = 0
for i in range(N - 1):
acc += abs(perm[i] - perm[i + 1])
max_value = max(max_value, acc)
return max_value
if __name__ == '__main__':
N = int(input())
numbers = list(map(int, sys.stdin.readline().split()))
answer = solution()
print(answer)
λ°μν
'π algorithm > boj' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
BOJ 1260 - DFSμ BFS (0) | 2021.03.18 |
---|---|
BOJ 6550 - λΆλΆ λ¬Έμμ΄ (0) | 2021.03.18 |
BOJ 15240 - Paint bucket (0) | 2021.03.18 |
BOJ 1449 - μ리곡 νμΉ (0) | 2021.03.18 |
BOJ 2805 - λ무 μλ₯΄κΈ° (0) | 2021.03.18 |
π¬ λκΈ