본문 바로가기
백준

[Python] 백준 대피소

by MINU.SHINNNN 2024. 9. 25.

https://www.acmicpc.net/problem/28215

 

from itertools import combinations
import sys

# sys.stdin = open('input.txt')
N, K = map(int, input().split())
X = []
Y = []

for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

def sol(c):
    b = 0
    for h_idx in range(N):
        a = 100000
        for c_idx in c:
            a = min(a, abs(X[h_idx] - X[c_idx]) + abs(Y[h_idx] - Y[c_idx]))

        b = max(b, a)
    return b

final = 100000
for c in combinations(range(N), K):
    final = min(final, sol(c))

print(final)

'백준' 카테고리의 다른 글

[Python] 백준 9935번 문자열 폭발  (0) 2024.09.27
[C++] 백준 전자레인지  (0) 2024.06.20
[C++] 백준 세탁소 사장 동혁  (0) 2024.06.20
[C++] 백준 고층 건물  (0) 2024.06.18
[C++] 백준 투명  (0) 2024.06.18