본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬]13221번 Manhattan

by 현장 2021. 4. 19.

-코드

x, y = list(map(int, input().split()))
t = int(input())
r1 = r2 = 100

for i in range(t):
    x2, y2 = list(map(int, input().split()))

    if abs(x - x2) + abs(y - y2) <= abs(r1 - x) + abs(r2 - y):
        r1 = x2
        r2 = y2
print(r1, r2)