結果
問題 | No.1998 Manhattan Restaurant |
ユーザー | mkawa2 |
提出日時 | 2022-07-01 23:44:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 318 ms / 2,000 ms |
コード長 | 1,660 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 82,956 KB |
最終ジャッジ日時 | 2024-05-04 18:15:11 |
合計ジャッジ時間 | 7,073 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
52,608 KB |
testcase_01 | AC | 38 ms
52,736 KB |
testcase_02 | AC | 38 ms
52,096 KB |
testcase_03 | AC | 42 ms
52,736 KB |
testcase_04 | AC | 39 ms
52,224 KB |
testcase_05 | AC | 38 ms
52,864 KB |
testcase_06 | AC | 77 ms
71,680 KB |
testcase_07 | AC | 127 ms
76,544 KB |
testcase_08 | AC | 140 ms
76,160 KB |
testcase_09 | AC | 135 ms
76,416 KB |
testcase_10 | AC | 98 ms
74,880 KB |
testcase_11 | AC | 67 ms
65,408 KB |
testcase_12 | AC | 48 ms
61,568 KB |
testcase_13 | AC | 63 ms
66,176 KB |
testcase_14 | AC | 83 ms
75,264 KB |
testcase_15 | AC | 231 ms
82,068 KB |
testcase_16 | AC | 184 ms
79,540 KB |
testcase_17 | AC | 191 ms
80,884 KB |
testcase_18 | AC | 211 ms
80,040 KB |
testcase_19 | AC | 228 ms
80,472 KB |
testcase_20 | AC | 230 ms
82,328 KB |
testcase_21 | AC | 267 ms
82,956 KB |
testcase_22 | AC | 290 ms
82,696 KB |
testcase_23 | AC | 318 ms
82,832 KB |
testcase_24 | AC | 290 ms
82,952 KB |
testcase_25 | AC | 138 ms
77,440 KB |
testcase_26 | AC | 216 ms
80,500 KB |
testcase_27 | AC | 211 ms
79,616 KB |
testcase_28 | AC | 219 ms
80,828 KB |
testcase_29 | AC | 190 ms
79,360 KB |
testcase_30 | AC | 232 ms
81,656 KB |
testcase_31 | AC | 210 ms
81,528 KB |
testcase_32 | AC | 136 ms
77,184 KB |
testcase_33 | AC | 186 ms
79,548 KB |
testcase_34 | AC | 208 ms
80,760 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = (1 << 63)-1 inf = (1 << 31)-1 md = 10**9+7 # md = 998244353 from bisect import * n = II() # ii,jj=set(),set() il = jl = inf ir = jr = -inf ij = [] for _ in range(n): x, y = LI() i = x+y j = x-y ij.append((i, j)) il = min(il, i) ir = max(ir, i) jl = min(jl, j) jr = max(jr, j) def binary_search(l, r, ok, minimize): if minimize: l -= 1 else: r += 1 while l+1 < r: m = (l+r)//2 if ok(m) ^ minimize: l = m else: r = m if minimize: return r return l def ok(m): i1, j1 = il+m, jl+m i2, j2 = ir-m, jr-m # print(m, i1, j1, i2, j2) ng1 = ng2 = False for i, j in ij: d = min(max(abs(i-i1), abs(j-j1)), max(abs(i-i2), abs(j-j2))) if d > m: ng1 = True d = min(max(abs(i-i1), abs(j-j2)), max(abs(i-i2), abs(j-j1))) if d > m: ng2 = True if ng1 & ng2: return False return True r = max((ir-il)//2, (jr-jl)//2) # pDB(r) ans = binary_search(0, r, ok, True) print(ans)