結果
問題 | No.2436 Min Diff Distance |
ユーザー | Shirotsume |
提出日時 | 2023-08-18 22:17:55 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,980 bytes |
コンパイル時間 | 468 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 147,484 KB |
最終ジャッジ日時 | 2024-05-06 04:29:41 |
合計ジャッジ時間 | 29,135 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 48 ms
55,552 KB |
testcase_01 | AC | 47 ms
55,552 KB |
testcase_02 | AC | 47 ms
55,808 KB |
testcase_03 | TLE | - |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | TLE | - |
testcase_09 | AC | 45 ms
55,552 KB |
testcase_10 | AC | 46 ms
55,552 KB |
testcase_11 | AC | 363 ms
131,584 KB |
testcase_12 | AC | 354 ms
132,608 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | TLE | - |
testcase_16 | WA | - |
testcase_17 | TLE | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
ソースコード
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)) 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[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)) 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)