結果

問題 No.2566 美しい整数列
ユーザー hiro1729hiro1729
提出日時 2023-12-02 15:20:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 170,916 KB
最終ジャッジ日時 2024-09-26 18:30:26
合計ジャッジ時間 6,765 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
s = [0]
for i in range(n - 1):
	s.append(s[-1] + b[i % m])
for i in range(n):
	a[i] -= s[i]
d = defaultdict(list)
for i in range(n):
	d[a[i]].append(c[i])
k = 0
for i, j in d.items():
	k = max(k, sum(j))
print(sum(c) - k)
0