結果

問題 No.545 ママの大事な二人の子供
ユーザー hedwig100hedwig100
提出日時 2020-05-29 12:12:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 502 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 45,592 KB
最終ジャッジ日時 2024-04-22 17:40:21
合計ジャッジ時間 17,052 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 490 ms
44,492 KB
testcase_01 AC 486 ms
44,500 KB
testcase_02 AC 485 ms
44,364 KB
testcase_03 AC 480 ms
44,496 KB
testcase_04 AC 487 ms
44,112 KB
testcase_05 AC 476 ms
44,756 KB
testcase_06 AC 476 ms
44,620 KB
testcase_07 AC 478 ms
44,884 KB
testcase_08 AC 485 ms
44,628 KB
testcase_09 AC 485 ms
44,112 KB
testcase_10 AC 489 ms
44,368 KB
testcase_11 AC 479 ms
44,492 KB
testcase_12 AC 484 ms
44,496 KB
testcase_13 AC 475 ms
44,492 KB
testcase_14 AC 489 ms
44,244 KB
testcase_15 AC 493 ms
44,112 KB
testcase_16 AC 485 ms
44,236 KB
testcase_17 AC 488 ms
44,496 KB
testcase_18 AC 491 ms
44,236 KB
testcase_19 AC 488 ms
44,240 KB
testcase_20 AC 483 ms
44,240 KB
testcase_21 AC 474 ms
43,952 KB
testcase_22 AC 484 ms
44,880 KB
testcase_23 AC 502 ms
45,208 KB
testcase_24 AC 489 ms
45,004 KB
testcase_25 AC 490 ms
45,384 KB
testcase_26 AC 493 ms
45,464 KB
testcase_27 AC 483 ms
45,580 KB
testcase_28 AC 490 ms
45,328 KB
testcase_29 AC 488 ms
45,332 KB
testcase_30 AC 489 ms
45,592 KB
testcase_31 AC 481 ms
45,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
INF = 1<<50
N = int(input())
satisf = [tuple(map(int,input().split())) for _ in range(N)]
if N == 1:
    print(min(satisf[0]))
    exit()
left = np.array([satisf[0][0],-satisf[0][1]])
for x,y in satisf[1:N//2]:
    left = np.concatenate([left + x,left - y])
right = np.array([satisf[N//2][0],-satisf[N//2][1]])
for x,y in satisf[N//2 + 1:]:
    right = np.concatenate([right + x,right - y])

right = np.append(right,INF)
right = np.append(right,-INF)
right = np.sort(np.unique(right))
idx = np.searchsorted(right,-left,'left')
ans1 = np.abs(left + right[idx]).min()
ans2 = np.abs(left + right[idx - 1]).min()
print(min(ans1,ans2))
0