結果

問題 No.904 サメトロ
ユーザー 👑 H20H20
提出日時 2021-08-03 10:29:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 635 bytes
コンパイル時間 1,390 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 76,344 KB
最終ジャッジ日時 2023-10-14 21:07:04
合計ジャッジ時間 5,919 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
71,516 KB
testcase_01 AC 84 ms
71,284 KB
testcase_02 AC 86 ms
71,348 KB
testcase_03 WA -
testcase_04 AC 84 ms
71,288 KB
testcase_05 AC 85 ms
71,240 KB
testcase_06 AC 86 ms
71,388 KB
testcase_07 WA -
testcase_08 AC 88 ms
71,236 KB
testcase_09 AC 87 ms
71,408 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 87 ms
71,584 KB
testcase_13 WA -
testcase_14 AC 87 ms
71,592 KB
testcase_15 AC 88 ms
71,384 KB
testcase_16 WA -
testcase_17 AC 86 ms
71,296 KB
testcase_18 AC 86 ms
71,520 KB
testcase_19 WA -
testcase_20 AC 85 ms
71,524 KB
testcase_21 WA -
testcase_22 AC 86 ms
71,296 KB
testcase_23 AC 85 ms
71,244 KB
testcase_24 AC 86 ms
71,096 KB
testcase_25 AC 85 ms
71,228 KB
testcase_26 WA -
testcase_27 AC 94 ms
76,092 KB
testcase_28 AC 85 ms
71,468 KB
testcase_29 AC 91 ms
75,932 KB
testcase_30 AC 86 ms
71,512 KB
testcase_31 AC 87 ms
71,656 KB
testcase_32 AC 84 ms
71,256 KB
testcase_33 AC 85 ms
71,408 KB
testcase_34 AC 85 ms
71,468 KB
testcase_35 AC 84 ms
71,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)

0