結果
問題 | No.904 サメトロ |
ユーザー |
|
提出日時 | 2022-05-25 22:07:16 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 28 ms / 1,000 ms |
コード長 | 455 bytes |
コンパイル時間 | 87 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-20 14:49:23 |
合計ジャッジ時間 | 2,085 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
n = int(input()) a_tot, b_tot = 0, 0 max_ = 0 for _ in range(n - 1): a, b = map(int, input().split()) a_tot += a b_tot += b max_ = max(max_, a + b) # それぞれの場合の数を計算するのがポイント # aが取り得る場合の数 max_a = b_tot min_a = max(0, max_ - a_tot) num_a = max_a - min_a + 1 # bが取り得る場合の数 max_b = a_tot min_b = max(0, max_ - b_tot) num_b = max_b - min_b + 1 print(min(num_a, num_b))