728x90
import sys
from itertools import combinations
input = sys.stdin.readline
n = int(input())
checkpoints = []
for _ in range(n):
x, y = map(int, input().split())
checkpoints.append([x, y])
answer = int(1e9)
for comb in combinations(checkpoints[1:-1], n-3):
temp = []
temp.append(checkpoints[0])
temp += list(comb)
temp.append(checkpoints[-1])
distance = 0
for i in range(n-2):
x1, y1 = temp[i]
x2, y2 = temp[i+1]
distance += abs(x1-x2) + abs(y1-y2)
answer = min(answer, distance)
print(answer)
728x90
'Algorithm (PS)' 카테고리의 다른 글
[LeetCode] Two Sum Python (0) | 2023.04.24 |
---|---|
[프로그래머스] 카펫 (Python) - 완전탐색/Brute Force (0) | 2023.04.06 |
[프로그래머스] 구명보트 Python (0) | 2023.03.25 |
[백준] 2573번 빙산 (Python) (0) | 2023.03.23 |
[프로그래머스] 큰 수 만들기 - Python (Greedy) (0) | 2023.03.22 |