結果

問題 No.2436 Min Diff Distance
ユーザー ShirotsumeShirotsume
提出日時 2023-08-18 22:10:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,345 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 129,732 KB
最終ジャッジ日時 2023-08-18 22:11:36
合計ジャッジ時間 18,683 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
74,232 KB
testcase_01 AC 126 ms
74,640 KB
testcase_02 AC 104 ms
74,304 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 107 ms
74,584 KB
testcase_10 AC 106 ms
74,420 KB
testcase_11 AC 367 ms
128,560 KB
testcase_12 AC 333 ms
129,732 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

n = ii()

XY = [li() + [i] for i in range(n)]

mini = [inf] * n

XY.sort(key = lambda x: x[0])
for i in range(n):
    x1, y1, ind1 = XY[i]
    if i > 0:
        x2, y2, _ = XY[i - 1]
        mini[ind1] = min(mini[ind1], abs(x1 - x2) + abs(y1 - y2))
    if i < n - 1:
        x2, y2, _ = XY[i + 1]
        mini[ind1] = min(mini[ind1], abs(x1 - x2) + abs(y1 - y2))

XY.sort(key = lambda x: x[1])

for i in range(n):
    x1, y1, ind1 = XY[i]
    if i > 0:
        x2, y2, _ = XY[i - 1]
        mini[ind1] = min(mini[ind1], abs(x1 - x2) + abs(y1 - y2))
    if i < n - 1:
        x2, y2, _ = XY[i + 1]
        mini[ind1] = min(mini[ind1], abs(x1 - x2) + abs(y1 - y2))


xmax = -inf
xmin = inf
ymax = -inf
ymin = inf
for i in range(n):
    x, y, ind = XY[i]
    XY[i] = [x + y, x - y, ind]
    xmax = max(xmax, x + y)
    xmin = min(xmin, x + y)
    ymax = max(ymax, x - y)
    ymin = min(ymin, x - y)
maxi = [0] * n
for i in range(n):
    x, y, ind = XY[i]
    maxi[ind] = max(xmax - x, x - xmin, ymax - y, y - ymin)

ans = inf        
for i in range(n):
    ans = min(ans, maxi[i] - mini[i])
print(ans)
0