結果

問題 No.545 ママの大事な二人の子供
ユーザー hedwig100hedwig100
提出日時 2020-05-29 12:08:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 617 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 46,100 KB
最終ジャッジ日時 2024-04-22 17:30:24
合計ジャッジ時間 20,021 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 494 ms
44,220 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 493 ms
44,220 KB
testcase_04 AC 494 ms
44,220 KB
testcase_05 AC 486 ms
44,736 KB
testcase_06 RE -
testcase_07 AC 481 ms
44,216 KB
testcase_08 AC 485 ms
44,344 KB
testcase_09 AC 489 ms
44,480 KB
testcase_10 AC 482 ms
44,348 KB
testcase_11 AC 494 ms
44,348 KB
testcase_12 AC 500 ms
44,480 KB
testcase_13 AC 492 ms
44,352 KB
testcase_14 AC 493 ms
44,476 KB
testcase_15 AC 490 ms
44,344 KB
testcase_16 AC 496 ms
44,600 KB
testcase_17 RE -
testcase_18 AC 493 ms
44,224 KB
testcase_19 AC 489 ms
44,616 KB
testcase_20 RE -
testcase_21 AC 483 ms
44,160 KB
testcase_22 RE -
testcase_23 AC 631 ms
46,012 KB
testcase_24 RE -
testcase_25 AC 494 ms
46,100 KB
testcase_26 AC 498 ms
46,008 KB
testcase_27 AC 492 ms
46,000 KB
testcase_28 RE -
testcase_29 AC 500 ms
45,996 KB
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

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.array([-INF] + np.sort(np.unique(right)) + [INF])
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