結果

問題 No.1998 Manhattan Restaurant
ユーザー 👑 tamatotamato
提出日時 2022-07-01 22:51:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 220 ms / 2,000 ms
コード長 1,820 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 83,196 KB
最終ジャッジ日時 2023-08-17 10:27:28
合計ジャッジ時間 6,121 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,248 KB
testcase_01 AC 72 ms
71,372 KB
testcase_02 AC 72 ms
71,260 KB
testcase_03 AC 72 ms
71,244 KB
testcase_04 AC 73 ms
71,348 KB
testcase_05 AC 73 ms
71,252 KB
testcase_06 AC 82 ms
75,384 KB
testcase_07 AC 104 ms
76,200 KB
testcase_08 AC 91 ms
75,596 KB
testcase_09 AC 104 ms
76,300 KB
testcase_10 AC 82 ms
75,556 KB
testcase_11 AC 83 ms
75,280 KB
testcase_12 AC 79 ms
75,512 KB
testcase_13 AC 82 ms
75,452 KB
testcase_14 AC 84 ms
75,760 KB
testcase_15 AC 158 ms
82,604 KB
testcase_16 AC 121 ms
80,036 KB
testcase_17 AC 129 ms
82,424 KB
testcase_18 AC 126 ms
80,180 KB
testcase_19 AC 137 ms
81,488 KB
testcase_20 AC 159 ms
82,488 KB
testcase_21 AC 208 ms
83,080 KB
testcase_22 AC 202 ms
82,664 KB
testcase_23 AC 220 ms
82,964 KB
testcase_24 AC 215 ms
83,196 KB
testcase_25 AC 93 ms
76,688 KB
testcase_26 AC 133 ms
81,652 KB
testcase_27 AC 125 ms
79,344 KB
testcase_28 AC 129 ms
81,480 KB
testcase_29 AC 117 ms
79,052 KB
testcase_30 AC 139 ms
82,428 KB
testcase_31 AC 147 ms
82,636 KB
testcase_32 AC 94 ms
76,600 KB
testcase_33 AC 126 ms
80,256 KB
testcase_34 AC 134 ms
82,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
inf = 2 * 10 ** 9 + 1


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    UV = []
    for _ in range(N):
        x, y = map(int, input().split())
        UV.append((x + y, x - y))

    u_min = inf
    u_max = -inf
    v_min = inf
    v_max = -inf
    for u, v in UV:
        u_min = min(u_min, u)
        u_max = max(u_max, u)
        v_min = min(v_min, v)
        v_max = max(v_max, v)

    ok = inf
    ng = -1
    mid = (ok + ng) // 2
    while ok - ng > 1:
        u0_min = u_min
        u0_max = u_min + mid * 2
        v0_min = v_min
        v0_max = v_min + mid * 2
        u1_min = u_max - mid * 2
        u1_max = u_max
        v1_min = v_max - mid * 2
        v1_max = v_max
        flg = 1
        for u, v in UV:
            tmp = 0
            if u0_min <= u <= u0_max and v0_min <= v <= v0_max:
                tmp = 1
            if u1_min <= u <= u1_max and v1_min <= v <= v1_max:
                tmp = 1
            if tmp == 0:
                flg = 0
                break
        if flg:
            ok = mid
            mid = (ok + ng) // 2
            continue

        u0_min = u_min
        u0_max = u_min + mid * 2
        v0_min = v_max - mid * 2
        v0_max = v_max
        u1_min = u_max - mid * 2
        u1_max = u_max
        v1_min = v_min
        v1_max = v_min + mid * 2
        flg = 1
        for u, v in UV:
            tmp = 0
            if u0_min <= u <= u0_max and v0_min <= v <= v0_max:
                tmp = 1
            if u1_min <= u <= u1_max and v1_min <= v <= v1_max:
                tmp = 1
            if tmp == 0:
                flg = 0
                break
        if flg:
            ok = mid
        else:
            ng = mid
        mid = (ok + ng) // 2
    print(ok)


if __name__ == '__main__':
    main()
0