結果
問題 | No.1998 Manhattan Restaurant |
ユーザー | mkawa2 |
提出日時 | 2022-07-01 23:44:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 282 ms / 2,000 ms |
コード長 | 1,660 bytes |
コンパイル時間 | 238 ms |
コンパイル使用メモリ | 82,120 KB |
実行使用メモリ | 82,828 KB |
最終ジャッジ日時 | 2024-11-26 07:50:08 |
合計ジャッジ時間 | 6,706 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
52,864 KB |
testcase_01 | AC | 37 ms
52,608 KB |
testcase_02 | AC | 35 ms
52,096 KB |
testcase_03 | AC | 36 ms
53,120 KB |
testcase_04 | AC | 39 ms
52,560 KB |
testcase_05 | AC | 35 ms
52,608 KB |
testcase_06 | AC | 65 ms
71,808 KB |
testcase_07 | AC | 113 ms
76,528 KB |
testcase_08 | AC | 112 ms
76,032 KB |
testcase_09 | AC | 119 ms
76,288 KB |
testcase_10 | AC | 78 ms
74,724 KB |
testcase_11 | AC | 54 ms
65,920 KB |
testcase_12 | AC | 45 ms
61,568 KB |
testcase_13 | AC | 56 ms
66,048 KB |
testcase_14 | AC | 76 ms
75,776 KB |
testcase_15 | AC | 221 ms
82,328 KB |
testcase_16 | AC | 167 ms
79,924 KB |
testcase_17 | AC | 172 ms
80,624 KB |
testcase_18 | AC | 204 ms
80,044 KB |
testcase_19 | AC | 217 ms
80,776 KB |
testcase_20 | AC | 220 ms
81,948 KB |
testcase_21 | AC | 268 ms
82,700 KB |
testcase_22 | AC | 280 ms
82,828 KB |
testcase_23 | AC | 275 ms
82,444 KB |
testcase_24 | AC | 282 ms
82,572 KB |
testcase_25 | AC | 117 ms
77,212 KB |
testcase_26 | AC | 202 ms
80,120 KB |
testcase_27 | AC | 205 ms
79,360 KB |
testcase_28 | AC | 197 ms
80,448 KB |
testcase_29 | AC | 183 ms
79,488 KB |
testcase_30 | AC | 217 ms
81,516 KB |
testcase_31 | AC | 198 ms
81,392 KB |
testcase_32 | AC | 123 ms
76,928 KB |
testcase_33 | AC | 166 ms
79,552 KB |
testcase_34 | AC | 192 ms
80,620 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)