結果

問題 No.2566 美しい整数列
ユーザー mkawa2mkawa2
提出日時 2023-12-02 15:34:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 1,111 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 171,112 KB
最終ジャッジ日時 2023-12-02 15:34:40
合計ジャッジ時間 6,436 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
55,608 KB
testcase_01 AC 47 ms
55,608 KB
testcase_02 AC 40 ms
55,608 KB
testcase_03 AC 39 ms
55,608 KB
testcase_04 AC 222 ms
150,072 KB
testcase_05 AC 224 ms
146,448 KB
testcase_06 AC 176 ms
142,304 KB
testcase_07 AC 175 ms
144,476 KB
testcase_08 AC 175 ms
144,380 KB
testcase_09 AC 179 ms
144,344 KB
testcase_10 AC 177 ms
144,340 KB
testcase_11 AC 206 ms
158,052 KB
testcase_12 AC 211 ms
158,408 KB
testcase_13 AC 210 ms
157,904 KB
testcase_14 AC 233 ms
158,288 KB
testcase_15 AC 210 ms
158,288 KB
testcase_16 AC 235 ms
171,112 KB
testcase_17 AC 234 ms
167,784 KB
testcase_18 AC 238 ms
168,684 KB
testcase_19 AC 168 ms
121,000 KB
testcase_20 AC 234 ms
168,984 KB
testcase_21 AC 232 ms
169,076 KB
testcase_22 AC 156 ms
123,412 KB
testcase_23 AC 185 ms
134,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = -1-(-1 << 31)
# inf = -1-(-1 << 63)
# md = 10**9+7
md = 998244353

from collections import defaultdict

n,m=LI()
aa=LI()
bb=LI()
cc=LI()

ss=[0]
for i in range(n-1):
    ss.append(ss[-1]+bb[i%m])
# print(ss)

d2i=defaultdict(list)
for i,(a,s) in enumerate(zip(aa,ss)):
    d=s-a
    d2i[d].append(i)

mx=0
for d in d2i:
    cost=0
    for i in d2i[d]:
        cost+=cc[i]
    mx=max(mx,cost)

print(sum(cc)-mx)
0