結果

問題 No.1998 Manhattan Restaurant
ユーザー MasKoaTSMasKoaTS
提出日時 2022-03-19 16:26:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,484 ms / 2,000 ms
コード長 980 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 11,948 KB
実行使用メモリ 24,040 KB
最終ジャッジ日時 2023-10-21 01:14:25
合計ジャッジ時間 20,685 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
9,992 KB
testcase_01 AC 26 ms
9,992 KB
testcase_02 AC 26 ms
9,992 KB
testcase_03 AC 26 ms
9,992 KB
testcase_04 AC 26 ms
9,992 KB
testcase_05 AC 26 ms
9,992 KB
testcase_06 AC 35 ms
10,044 KB
testcase_07 AC 34 ms
10,060 KB
testcase_08 AC 34 ms
10,060 KB
testcase_09 AC 36 ms
10,060 KB
testcase_10 AC 30 ms
10,036 KB
testcase_11 AC 28 ms
10,008 KB
testcase_12 AC 28 ms
9,996 KB
testcase_13 AC 27 ms
10,000 KB
testcase_14 AC 31 ms
10,060 KB
testcase_15 AC 734 ms
23,812 KB
testcase_16 AC 640 ms
17,440 KB
testcase_17 AC 891 ms
20,396 KB
testcase_18 AC 638 ms
17,720 KB
testcase_19 AC 678 ms
18,752 KB
testcase_20 AC 897 ms
23,812 KB
testcase_21 AC 1,473 ms
24,040 KB
testcase_22 AC 1,452 ms
24,040 KB
testcase_23 AC 1,471 ms
24,040 KB
testcase_24 AC 1,484 ms
24,040 KB
testcase_25 AC 93 ms
10,824 KB
testcase_26 AC 731 ms
18,548 KB
testcase_27 AC 482 ms
15,756 KB
testcase_28 AC 731 ms
18,744 KB
testcase_29 AC 494 ms
15,760 KB
testcase_30 AC 1,005 ms
22,420 KB
testcase_31 AC 924 ms
21,324 KB
testcase_32 AC 123 ms
11,300 KB
testcase_33 AC 608 ms
17,432 KB
testcase_34 AC 774 ms
19,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def main():
	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

	ok = 2 * 10 ** 9 + 1
	ng = -1
	while(ok - ng > 1):
		k = ok + ng
		f = False
		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)):
				break
			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
		else:
			if((block[0][0] | block[1][1]) == 0 or (block[0][1] | block[1][0]) == 0):
				f = True
		if(f):
			ok = k // 2
		else:
			ng = k // 2
	print(ok)

main()
0