結果

問題 No.904 サメトロ
ユーザー rkyiolklo
提出日時 2020-04-22 00:25:04
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 102 ms / 1,000 ms
コード長 345 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-09 15:56:51
合計ジャッジ時間 2,528 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    n=int(input())
    tota=totb=M=0
    for _ in range(n-1):
        a,b=map(int,input().split())
        tota+=a 
        totb+=b 
        M=max(M,a+b)

    ans=0
    for i in range(totb+1):
        j=i+tota-totb 
        if j<0 or j<M-totb:
            continue
        ans+=1
    print(ans)

if __name__ == '__main__':
    main()
0