結果

問題 No.3684 chokudai_niku.png
コンテスト
ユーザー Rapca1256
提出日時 2026-09-05 13:14:34
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 247 ms / 2,000 ms
+ 513µs
コード長 813 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 304 ms
コンパイル使用メモリ 21,340 KB
実行使用メモリ 46,960 KB
最終ジャッジ日時 2026-09-05 13:14:51
合計ジャッジ時間 15,345 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
import math

# 入力高速化
#input = sys.stdin.readline
# 再帰回数上限
sys.setrecursionlimit(10**9)

# よくあるmod
#MOD = 1000000007
MOD = 998244353

def is_inside(y, x, h, w):
  return (0 <= y < h and 0 <= x < w)

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    ans = 0
    
    for j in range(M):
        if A[j] - B[j] > 0: ans += A[j] - B[j]
    cur = ans
    for i in range(1, N):
        if i + M - 1 > N-1: continue
        if i - 1 >= 0 and A[i - 1] - B[i - 1] > 0: cur -= A[i - 1] - B[i - 1]
        if A[i + M - 1] - B[i + M - 1] > 0: cur += A[i + M - 1] - B[i + M - 1]
        ans = max(ans, cur)
    print(ans)
    
if __name__ == '__main__':
    T = 1
    for _ in range(T):
        solve()
0