結果
| 問題 | No.2566 美しい整数列 | 
| コンテスト | |
| ユーザー |  けんぴん | 
| 提出日時 | 2023-09-23 03:03:54 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 250 ms / 2,000 ms | 
| コード長 | 806 bytes | 
| コンパイル時間 | 283 ms | 
| コンパイル使用メモリ | 82,588 KB | 
| 実行使用メモリ | 184,032 KB | 
| 最終ジャッジ日時 | 2024-07-16 03:24:03 | 
| 合計ジャッジ時間 | 7,481 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 | 
ソースコード
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()
            
            
            
        