結果

問題 No.2566 美しい整数列
ユーザー lloyzlloyz
提出日時 2023-12-16 23:16:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 274 ms / 2,000 ms
コード長 388 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 176,268 KB
最終ジャッジ日時 2023-12-16 23:16:27
合計ジャッジ時間 7,434 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,460 KB
testcase_01 AC 41 ms
53,460 KB
testcase_02 AC 41 ms
53,460 KB
testcase_03 AC 41 ms
53,460 KB
testcase_04 AC 274 ms
170,636 KB
testcase_05 AC 252 ms
176,268 KB
testcase_06 AC 176 ms
141,792 KB
testcase_07 AC 173 ms
137,344 KB
testcase_08 AC 174 ms
139,248 KB
testcase_09 AC 175 ms
137,952 KB
testcase_10 AC 201 ms
137,948 KB
testcase_11 AC 188 ms
139,512 KB
testcase_12 AC 192 ms
139,084 KB
testcase_13 AC 187 ms
139,428 KB
testcase_14 AC 189 ms
139,604 KB
testcase_15 AC 195 ms
139,364 KB
testcase_16 AC 258 ms
160,036 KB
testcase_17 AC 230 ms
162,372 KB
testcase_18 AC 230 ms
163,104 KB
testcase_19 AC 170 ms
131,684 KB
testcase_20 AC 217 ms
159,168 KB
testcase_21 AC 248 ms
161,524 KB
testcase_22 AC 159 ms
131,924 KB
testcase_23 AC 189 ms
137,052 KB
権限があれば一括ダウンロードができます

ソースコード

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()))

Bs = [0]
for i in range(n - 1):
    Bs.append(Bs[-1] + B[i % m])

ans = sum(C)
sc = ans
d = defaultdict(int)
for i in range(n):
    d[A[i] - Bs[i]] += C[i]
for x in d:
    ans = min(ans, sc - d[x])
print(ans)
0