結果

問題 No.2566 美しい整数列
ユーザー けんぴんけんぴん
提出日時 2023-09-23 03:03:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 181,208 KB
最終ジャッジ日時 2023-09-23 03:04:07
合計ジャッジ時間 10,366 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,488 KB
testcase_01 AC 93 ms
71,316 KB
testcase_02 AC 93 ms
71,312 KB
testcase_03 AC 94 ms
71,632 KB
testcase_04 AC 290 ms
178,948 KB
testcase_05 AC 287 ms
181,208 KB
testcase_06 AC 249 ms
144,292 KB
testcase_07 AC 240 ms
148,160 KB
testcase_08 AC 242 ms
146,572 KB
testcase_09 AC 242 ms
147,656 KB
testcase_10 AC 242 ms
147,552 KB
testcase_11 AC 250 ms
147,520 KB
testcase_12 AC 253 ms
148,288 KB
testcase_13 AC 252 ms
147,616 KB
testcase_14 AC 250 ms
148,192 KB
testcase_15 AC 255 ms
147,972 KB
testcase_16 AC 254 ms
143,312 KB
testcase_17 AC 269 ms
152,608 KB
testcase_18 AC 266 ms
153,628 KB
testcase_19 AC 222 ms
143,808 KB
testcase_20 AC 254 ms
145,432 KB
testcase_21 AC 264 ms
153,532 KB
testcase_22 AC 214 ms
136,264 KB
testcase_23 AC 251 ms
164,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    C = list(map(int,input().split()))
    assert 1 <= M < N <= 2*10**5
    for a in A:
        assert -10**9 <= a <= 10**9
    for b in B:
        assert -10**9 <= b <= 10**9
    for c in C:
        assert 1 <= c <= 10**9
    A_hope = [A[0]]
    for i in range(N-1):
        A_hope.append(A_hope[-1]+B[i%M])
    # print(A_hope)
    diff_hope = []
    for i in range(N):
        diff_hope.append(A[i]-A_hope[i])
    # print(diff_hope)
    C_per_diff = defaultdict(int)
    for i in range(N):
        C_per_diff[diff_hope[i]] += C[i]
    # print(C_per_diff)
    print(sum(C) - max(C_per_diff.values()))
    
if __name__ == "__main__":
    main()
0