結果

問題 No.2566 美しい整数列
ユーザー navel_tosnavel_tos
提出日時 2023-12-02 16:01:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 161,272 KB
最終ジャッジ日時 2023-12-02 16:01:22
合計ジャッジ時間 6,129 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,460 KB
testcase_01 AC 41 ms
53,460 KB
testcase_02 AC 40 ms
53,460 KB
testcase_03 AC 41 ms
53,460 KB
testcase_04 AC 227 ms
159,264 KB
testcase_05 AC 231 ms
161,272 KB
testcase_06 AC 177 ms
141,792 KB
testcase_07 AC 171 ms
137,736 KB
testcase_08 AC 172 ms
139,256 KB
testcase_09 AC 171 ms
137,960 KB
testcase_10 AC 170 ms
137,960 KB
testcase_11 AC 186 ms
137,728 KB
testcase_12 AC 188 ms
138,320 KB
testcase_13 AC 186 ms
137,732 KB
testcase_14 AC 185 ms
137,812 KB
testcase_15 AC 189 ms
137,452 KB
testcase_16 AC 207 ms
149,116 KB
testcase_17 AC 213 ms
150,668 KB
testcase_18 AC 216 ms
151,064 KB
testcase_19 AC 169 ms
136,040 KB
testcase_20 AC 208 ms
147,928 KB
testcase_21 AC 206 ms
150,292 KB
testcase_22 AC 152 ms
124,756 KB
testcase_23 AC 186 ms
138,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#緑以下J

from collections import defaultdict

#入力受取
N,M = map(int,input().split())
A,B,C = [list(map(int,input().split())) for _ in range(3)]

#もしA[0] = 0で固定するなら、他の値はいくつであるべき?
D = [0]*N
for i in range(N-1):
    D[i+1] = B[i%M] + D[i]

#基線を定める。基線に乗っている場合、C[i]ぶん減額する。
E = defaultdict(int)
for i,cost in enumerate(C):
    E[D[i]-A[i]] += cost
ans = 10**18
base = sum(C)
for c in E.keys():
    ans = min(ans, base-E[c])
print(ans)
0