結果

問題 No.904 サメトロ
ユーザー kohei2019
提出日時 2022-08-01 23:49:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 191 ms / 1,000 ms
コード長 417 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 81,756 KB
実行使用メモリ 76,224 KB
最終ジャッジ日時 2024-07-22 14:40:25
合計ジャッジ時間 3,782 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
lsA = []
lsB = []
for i in range(N-1):
    A,B = map(int,input().split())
    lsA.append(A)
    lsB.append(B)
sumA = sum(lsA)
sumB = sum(lsB)
ans = min(sumA,sumB)

cnt = 0
for i in range(sumA+sumB,max(sumA,sumB)-1,-1):
    f = True
    lsA1 = lsA[:]+[i-sumA]
    lsB1 = lsB[:]+[i-sumB]
    for j in range(N):
        if lsA1[j] > i-lsB1[j]:
            f = False
    if f:
        cnt += 1
print(cnt)
0