結果

問題 No.3684 chokudai_niku.png
コンテスト
ユーザー 2251799813685248
提出日時 2026-09-09 00:13:06
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 98 ms / 2,000 ms
+ 102µs
コード長 339 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,056 ms
コンパイル使用メモリ 80,512 KB
実行使用メモリ 138,992 KB
最終ジャッジ日時 2026-09-09 00:13:26
合計ジャッジ時間 9,040 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = 0
for i in range(M):
	if a[i] >= b[i]:
		s += a[i]-b[i]
ans = -1
ans = max(ans, s)
for i in range(N-M):
	e = i
	f = i+M
	if a[e] >= b[e]:
		s -= a[e]-b[e]
	if a[f] >= b[f]:
		s += a[f]-b[f]
	ans = max(ans, s)
	# print(s)
print(ans)
0