結果
問題 |
No.904 サメトロ
|
ユーザー |
![]() |
提出日時 | 2021-08-03 10:29:34 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 635 bytes |
コンパイル時間 | 283 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 61,952 KB |
最終ジャッジ日時 | 2024-09-16 14:55:07 |
合計ジャッジ時間 | 3,097 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 WA * 9 |
ソースコード
import copy N = int(input()) A = [] B = [] for i in range(N-1): a,b = map(int,input().split()) A.append(a) B.append(b) ma = max(sum(A),sum(B)) amarib = 0 D = copy.deepcopy(A) for i in range(len(A)): b = B[i] for j in reversed(range(len(A))): if i==j: continue temp = min(D[j],b) b-=temp D[j]-=temp amarib += b amaria = 0 D = copy.deepcopy(B) for i in range(len(A)): a = A[i] for j in reversed(range(len(A))): if i==j: continue temp = min(D[j],a) a-=temp D[j]-=temp amaria += a print(ma-max(amaria,amarib)+1)