結果

問題 No.1998 Manhattan Restaurant
ユーザー MasKoaTSMasKoaTS
提出日時 2022-03-24 13:54:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,590 ms / 2,000 ms
コード長 947 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 12,108 KB
実行使用メモリ 24,224 KB
最終ジャッジ日時 2023-10-21 01:15:24
合計ジャッジ時間 19,988 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,172 KB
testcase_01 AC 28 ms
10,172 KB
testcase_02 AC 28 ms
10,172 KB
testcase_03 AC 27 ms
10,172 KB
testcase_04 AC 27 ms
10,172 KB
testcase_05 AC 26 ms
10,172 KB
testcase_06 AC 33 ms
10,228 KB
testcase_07 AC 36 ms
10,244 KB
testcase_08 AC 35 ms
10,244 KB
testcase_09 AC 36 ms
10,244 KB
testcase_10 AC 31 ms
10,220 KB
testcase_11 AC 31 ms
10,192 KB
testcase_12 AC 30 ms
10,176 KB
testcase_13 AC 29 ms
10,184 KB
testcase_14 AC 38 ms
10,244 KB
testcase_15 AC 833 ms
23,996 KB
testcase_16 AC 708 ms
17,624 KB
testcase_17 AC 1,044 ms
20,580 KB
testcase_18 AC 724 ms
17,904 KB
testcase_19 AC 781 ms
18,936 KB
testcase_20 AC 1,025 ms
23,996 KB
testcase_21 AC 1,577 ms
24,224 KB
testcase_22 AC 1,590 ms
24,224 KB
testcase_23 AC 1,557 ms
24,224 KB
testcase_24 AC 1,567 ms
24,224 KB
testcase_25 AC 100 ms
11,008 KB
testcase_26 AC 733 ms
18,732 KB
testcase_27 AC 519 ms
15,940 KB
testcase_28 AC 816 ms
18,928 KB
testcase_29 AC 550 ms
15,944 KB
testcase_30 AC 1,141 ms
22,604 KB
testcase_31 AC 1,057 ms
21,508 KB
testcase_32 AC 143 ms
11,472 KB
testcase_33 AC 681 ms
17,616 KB
testcase_34 AC 870 ms
19,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
INF = 10 ** 18

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

max_x = max_y = -INF
min_x = min_y = INF
for x, y in P:
	if(max_x < x):
		max_x = x
	if(max_y < y):
		max_y = y
	if(min_x > x):
		min_x = x
	if(min_y > y):
		min_y = y

def func(k):
	k *= 2
	block = [[0] * 2 for _ in [0] * 2]
	for x, y in P:
		if((x < max_x - k and x > min_x + k) or (y < max_y - k and y > min_y + k)):
			return False
		if(x < max_x - k and y < max_y - k):
			block[0][0] = 1
		if(x > min_x + k and y < max_y - k):
			block[1][0] = 1
		if(x < max_x - k and y > min_y + k):
			block[0][1] = 1
		if(x > min_x + k and y > min_y + k):
			block[1][1] = 1
	if((block[0][0] | block[1][1]) == 0 or (block[0][1] | block[1][0]) == 0):
		return True
	return False

ok = 2 * 10 ** 9 + 1
ng = -1
while(ok - ng > 1):
	k = (ok + ng) // 2
	if(func(k)):
		ok = k
	else:
		ng = k
print(ok)
0