Created
December 2, 2023 07:41
-
-
Save maehrm/5d33687cdbcbf2b1b9ef32cb0e6cc41d to your computer and use it in GitHub Desktop.
036 - Max Manhattan Distance(★5) https://atcoder.jp/contests/typical90/tasks/typical90_aj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N, Q = map(int, input().split()) | |
u, v = [], [] | |
for _ in range(N): | |
x, y = map(int, input().split()) | |
u.append(x + y) | |
v.append(x - y) | |
u_max, u_min = max(u), min(u) | |
v_max, v_min = max(v), min(v) | |
for _ in range(Q): | |
q = int(input()) - 1 | |
ans = max( | |
abs(u[q] - u_max), abs(u[q] - u_min), abs(v[q] - v_max), abs(v[q] - v_min) | |
) | |
print(ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment