結果
問題 | No.2897 2集合間距離 |
ユーザー | detteiuu |
提出日時 | 2024-09-20 22:47:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,129 ms / 3,500 ms |
コード長 | 1,369 bytes |
コンパイル時間 | 734 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 293,760 KB |
最終ジャッジ日時 | 2024-09-20 22:47:58 |
合計ジャッジ時間 | 17,663 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 411 ms
206,080 KB |
testcase_01 | AC | 383 ms
206,080 KB |
testcase_02 | AC | 410 ms
206,208 KB |
testcase_03 | AC | 413 ms
205,944 KB |
testcase_04 | AC | 387 ms
205,948 KB |
testcase_05 | AC | 391 ms
206,336 KB |
testcase_06 | AC | 412 ms
206,080 KB |
testcase_07 | AC | 387 ms
206,080 KB |
testcase_08 | AC | 392 ms
206,240 KB |
testcase_09 | AC | 407 ms
206,080 KB |
testcase_10 | AC | 392 ms
205,516 KB |
testcase_11 | AC | 392 ms
205,184 KB |
testcase_12 | AC | 467 ms
218,020 KB |
testcase_13 | AC | 442 ms
216,832 KB |
testcase_14 | AC | 496 ms
220,032 KB |
testcase_15 | AC | 541 ms
222,116 KB |
testcase_16 | AC | 1,064 ms
293,760 KB |
testcase_17 | AC | 1,129 ms
293,632 KB |
testcase_18 | AC | 1,060 ms
293,632 KB |
testcase_19 | AC | 1,047 ms
293,596 KB |
testcase_20 | AC | 1,124 ms
293,632 KB |
testcase_21 | AC | 1,099 ms
292,992 KB |
testcase_22 | AC | 1,103 ms
292,992 KB |
testcase_23 | AC | 1,043 ms
293,248 KB |
ソースコード
N = int(input()) XY = [list(map(int, input().split())) for _ in range(N)] M = int(input()) ZW = [list(map(int, input().split())) for _ in range(M)] for i in range(N): X, Y = XY[i] XY[i] = [X+Y+10**3-1, X-Y+10**3-1] for i in range(M): Z, W = ZW[i] ZW[i] = [Z+W+10**3-1, Z-W+10**3-1] cumS = [[0]*(10**3*3+1) for _ in range(10**3*3+1)] cumT = [[0]*(10**3*3+1) for _ in range(10**3*3+1)] for X, Y in XY: cumS[X+1][Y+1] = 1 for Z, W in ZW: cumT[Z+1][W+1] = 1 for i in range(1, 10**3*3+1): for j in range(2, 10**3*3+1): cumS[i][j] += cumS[i][j-1] cumT[i][j] += cumT[i][j-1] for i in range(2, 10**3*3+1): for j in range(1, 10**3*3+1): cumS[i][j] += cumS[i-1][j] cumT[i][j] += cumT[i-1][j] def sumS(i, j, n): return cumS[i+n][j+n]+cumS[i][j]-cumS[i+n][j]-cumS[i][j+n] def sumT(i, j, n): return cumT[i+n][j+n]+cumT[i][j]-cumT[i+n][j]-cumT[i][j+n] def func(x, y, n): return cumT[min(x+n+1, 10**3*3)][min(y+n+1, 10**3*3)]+cumT[max(x-n, 0)][max(y-n, 0)]-cumT[min(x+n+1, 10**3*3)][max(y-n, 0)]-cumT[max(x-n, 0)][min(y+n+1, 10**3*3)] ans = 10**18 for i in range(N): X, Y = XY[i] left = -1 right = 10**3 while left+1 < right: mid = (left+right)//2 if func(X, Y, mid) == 0: left = mid else: right = mid ans = min(ans, right) print(ans)