結果

問題 No.2612 Close the Distance
ユーザー chineristACchineristAC
提出日時 2024-01-19 23:15:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,153 ms / 3,000 ms
コード長 1,791 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 289,152 KB
最終ジャッジ日時 2024-04-05 16:39:13
合計ジャッジ時間 37,049 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
56,240 KB
testcase_01 AC 38 ms
56,240 KB
testcase_02 AC 39 ms
58,332 KB
testcase_03 AC 73 ms
77,172 KB
testcase_04 AC 73 ms
77,036 KB
testcase_05 AC 76 ms
77,052 KB
testcase_06 AC 1,371 ms
282,352 KB
testcase_07 AC 1,377 ms
266,480 KB
testcase_08 AC 1,361 ms
285,168 KB
testcase_09 AC 1,327 ms
268,144 KB
testcase_10 AC 1,331 ms
279,152 KB
testcase_11 AC 1,316 ms
269,168 KB
testcase_12 AC 1,355 ms
275,184 KB
testcase_13 AC 1,347 ms
270,572 KB
testcase_14 AC 1,343 ms
266,992 KB
testcase_15 AC 1,365 ms
270,956 KB
testcase_16 AC 2,122 ms
283,824 KB
testcase_17 AC 2,060 ms
277,060 KB
testcase_18 AC 2,052 ms
283,124 KB
testcase_19 AC 2,143 ms
289,152 KB
testcase_20 AC 2,112 ms
284,196 KB
testcase_21 AC 2,081 ms
282,528 KB
testcase_22 AC 2,068 ms
283,212 KB
testcase_23 AC 2,123 ms
282,564 KB
testcase_24 AC 2,153 ms
284,500 KB
testcase_25 AC 2,148 ms
279,096 KB
testcase_26 AC 39 ms
56,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import permutations
from heapq import heappop,heappush
from collections import deque
import random
import bisect
from math import gcd


input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())



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



def cond_2sq(tmp_xy,D):
    if not tmp_xy:
        return True
    x_min,x_max = min(x for x,y in tmp_xy),max(x for x,y in tmp_xy)
    y_min,y_max = min(y for x,y in tmp_xy),max(y for x,y in tmp_xy)

    """
    x_min,y_minを同時達成 or x_max,y_minを同時達成
    """
    for px,py in [(x_min,y_min),(x_max-D,y_min)]:
        tmp_x_min,tmp_x_max = x_max,x_min
        tmp_y_min,tmp_y_max = y_max,y_min
        for x,y in tmp_xy:
            if not px <= x <= px + D or not py <= y <= py + D:
                tmp_x_min = min(tmp_x_min,x)
                tmp_x_max = max(tmp_x_max,x)
                tmp_y_min = min(tmp_y_min,y)
                tmp_y_max = max(tmp_y_max,y)
        if (tmp_x_max-tmp_x_min) <= D and (tmp_y_max-tmp_y_min) <= D:
            return True
    return False

res = 10**10
#print("xy",xy)
for _ in range(4):
    x_min,y_min = min(x for x,y in xy),min(y for x,y in xy)
    #print(x_min,y_min)
    def cond_3sq(D):
        tmp_xy = []
        #print(x_min,y_min)
        for x,y in xy:
            if not x_min <= x <= x_min+D or not y_min <= y <= y_min+D:
                tmp_xy.append((x,y))
        #print(tmp_xy)
        return cond_2sq(tmp_xy,D)
    #print(cond_3sq(47))
    
    ok = res
    ng = -1
    while ok-ng>1:
        mid = (ok+ng)//2
        if cond_3sq(mid):
            ok = mid
        else:
            ng = mid
    res = ok

    xy = [(-y,x) for x,y in xy]

print(res)
        
0