結果

問題 No.904 サメトロ
ユーザー H3PO4
提出日時 2022-07-17 09:24:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 835 ms / 1,000 ms
コード長 339 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 78,568 KB
最終ジャッジ日時 2024-06-29 10:56:24
合計ジャッジ時間 22,089 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

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