結果
問題 | No.2436 Min Diff Distance |
ユーザー | Shirotsume |
提出日時 | 2023-08-18 22:15:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,361 bytes |
コンパイル時間 | 502 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 144,584 KB |
最終ジャッジ日時 | 2024-05-06 04:24:40 |
合計ジャッジ時間 | 11,666 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
55,296 KB |
testcase_01 | AC | 50 ms
55,168 KB |
testcase_02 | AC | 50 ms
55,680 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 50 ms
55,296 KB |
testcase_10 | AC | 53 ms
55,296 KB |
testcase_11 | AC | 361 ms
126,336 KB |
testcase_12 | AC | 362 ms
126,848 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 | - |
ソースコード
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)