結果

問題 No.2436 Min Diff Distance
ユーザー ShirotsumeShirotsume
提出日時 2023-08-18 22:15:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,361 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 149,072 KB
最終ジャッジ日時 2023-08-18 22:15:52
合計ジャッジ時間 27,418 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
74,240 KB
testcase_01 AC 124 ms
74,432 KB
testcase_02 AC 126 ms
74,416 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 128 ms
74,436 KB
testcase_10 AC 126 ms
74,728 KB
testcase_11 AC 475 ms
137,352 KB
testcase_12 AC 451 ms
137,372 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], 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))

XY.sort(key = lambda x: (x[1], 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))


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