結果

問題 No.904 サメトロ
ユーザー ntuda
提出日時 2025-07-08 20:54:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 86 ms / 1,000 ms
コード長 347 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 82,768 KB
実行使用メモリ 67,932 KB
最終ジャッジ日時 2025-07-08 20:54:10
合計ジャッジ時間 3,442 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
AB = []
XA, XB = 0, 0
for i in range(N - 1):
    a, b = map(int, input().split())
    AB.append((a, b))
    XA += a
    XB += b
cnt = 0
for a0 in range(XB + 1):
    b0 = XA + a0 - XB
    if b0 < 0 or b0 > XA:
        continue
    for a, b in AB:
        if a > XB + b0 - b:
            break
    else:
        cnt += 1
print(cnt)
0