結果

問題 No.904 サメトロ
ユーザー H3PO4H3PO4
提出日時 2022-07-17 09:24:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 134 ms / 1,000 ms
コード長 339 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 10,672 KB
実行使用メモリ 29,796 KB
最終ジャッジ日時 2023-09-11 21:09:31
合計ジャッジ時間 8,762 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
29,748 KB
testcase_01 AC 134 ms
29,664 KB
testcase_02 AC 131 ms
29,716 KB
testcase_03 AC 134 ms
29,724 KB
testcase_04 AC 131 ms
29,756 KB
testcase_05 AC 130 ms
29,760 KB
testcase_06 AC 128 ms
29,796 KB
testcase_07 AC 129 ms
29,628 KB
testcase_08 AC 129 ms
29,732 KB
testcase_09 AC 130 ms
29,648 KB
testcase_10 AC 130 ms
29,776 KB
testcase_11 AC 129 ms
29,692 KB
testcase_12 AC 129 ms
29,756 KB
testcase_13 AC 131 ms
29,708 KB
testcase_14 AC 130 ms
29,712 KB
testcase_15 AC 130 ms
29,796 KB
testcase_16 AC 130 ms
29,736 KB
testcase_17 AC 129 ms
29,712 KB
testcase_18 AC 132 ms
29,736 KB
testcase_19 AC 131 ms
29,720 KB
testcase_20 AC 132 ms
29,620 KB
testcase_21 AC 131 ms
29,692 KB
testcase_22 AC 133 ms
29,716 KB
testcase_23 AC 134 ms
29,720 KB
testcase_24 AC 134 ms
29,708 KB
testcase_25 AC 133 ms
29,696 KB
testcase_26 AC 133 ms
29,716 KB
testcase_27 AC 131 ms
29,768 KB
testcase_28 AC 130 ms
29,644 KB
testcase_29 AC 128 ms
29,768 KB
testcase_30 AC 129 ms
29,656 KB
testcase_31 AC 130 ms
29,596 KB
testcase_32 AC 130 ms
29,696 KB
testcase_33 AC 129 ms
29,704 KB
testcase_34 AC 129 ms
29,736 KB
testcase_35 AC 130 ms
29,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N = int(input())
AB = np.array(tuple(tuple(map(int, input().split())) for _ in range(N - 1)))

a1_max = np.sum(AB[:, 1])
b1_max = np.sum(AB[:, 0])
other_sum_max = np.max(np.sum(AB, axis=1))
a1_min = max(0, other_sum_max - b1_max)
b1_min = max(0, other_sum_max - a1_max)
print(min(a1_max - a1_min, b1_max - b1_min) + 1)
0