結果

問題 No.3684 chokudai_niku.png
コンテスト
ユーザー Kato, H.
提出日時 2026-09-05 14:53:27
言語 PyPy3
(7.3.23)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 138 ms / 2,000 ms
+ 218µs
コード長 529 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 272 ms
コンパイル使用メモリ 95,692 KB
実行使用メモリ 152,704 KB
最終ジャッジ日時 2026-09-05 14:53:49
合計ジャッジ時間 11,670 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# -*- coding: utf-8 -*-


def main():
    import sys

    input = sys.stdin.readline

    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = []
    ans = 0

    for ai, bi in zip(a, b):
        diff = ai - bi
        diff = max(0, diff)

        c.append(diff)

    total = 0

    for j in range(n):
        total += c[j]

        if j >= m:
            total -= c[j - m]

        ans = max(ans, total)

    print(ans)


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