結果

問題 No.2566 美しい整数列
ユーザー 21kazu13
提出日時 2023-12-04 15:19:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 1,276 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 160,684 KB
最終ジャッジ日時 2024-09-26 23:01:58
合計ジャッジ時間 7,435 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys
from bisect import bisect_left, bisect_right, insort_left, insort_right  # type: ignore
from collections import Counter, defaultdict, deque  # type: ignore
from math import gcd, sqrt, ceil, factorial  # type: ignore
from heapq import heapify, heappop, heappush, heappushpop, heapreplace, merge  # type: ignore
from itertools import accumulate, combinations, permutations, product  # type: ignore
from string import ascii_lowercase, ascii_uppercase # type: ignore

def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode("utf-8").split()
def S(): return sys.stdin.buffer.readline().rstrip().decode("utf-8")
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def SRL(n): return [list(S()) for _ in range(n)]

N,M = LI()
A = LI()
tmp = LI()*((N+M-1)//M)
B = tmp[:N-1]
acc = list(accumulate(B,initial=0))
C = LI()
sumc = sum(C)
d = defaultdict(int)
for i in range(N):
    a0 = A[i]-acc[i]
    d[a0] += C[i]
ans = 10**18
for k,v in d.items():
    ans = min(
        ans,
        sumc-v
    )
print(ans)
0