結果

問題 No.2603 Tone Correction
ユーザー KudeKude
提出日時 2024-01-12 22:42:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 328 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 147,488 KB
最終ジャッジ日時 2024-01-12 22:42:22
合計ジャッジ時間 6,340 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 34 ms
53,460 KB
testcase_03 AC 43 ms
62,212 KB
testcase_04 AC 43 ms
62,212 KB
testcase_05 AC 43 ms
62,212 KB
testcase_06 AC 43 ms
62,212 KB
testcase_07 AC 43 ms
62,212 KB
testcase_08 AC 45 ms
62,212 KB
testcase_09 AC 43 ms
62,212 KB
testcase_10 AC 43 ms
62,212 KB
testcase_11 AC 43 ms
62,212 KB
testcase_12 AC 43 ms
62,212 KB
testcase_13 AC 179 ms
146,976 KB
testcase_14 AC 183 ms
146,972 KB
testcase_15 AC 180 ms
147,228 KB
testcase_16 AC 179 ms
146,980 KB
testcase_17 AC 181 ms
147,360 KB
testcase_18 AC 187 ms
147,100 KB
testcase_19 AC 176 ms
147,228 KB
testcase_20 AC 179 ms
147,104 KB
testcase_21 AC 178 ms
147,232 KB
testcase_22 AC 182 ms
147,488 KB
testcase_23 AC 160 ms
125,788 KB
testcase_24 AC 166 ms
125,784 KB
testcase_25 AC 157 ms
125,904 KB
testcase_26 AC 157 ms
125,784 KB
testcase_27 AC 161 ms
126,172 KB
testcase_28 AC 162 ms
125,528 KB
testcase_29 AC 157 ms
125,528 KB
testcase_30 AC 157 ms
125,532 KB
testcase_31 AC 167 ms
125,532 KB
testcase_32 AC 157 ms
125,528 KB
testcase_33 AC 35 ms
53,460 KB
testcase_34 AC 139 ms
144,700 KB
testcase_35 AC 139 ms
144,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.append(0)
b.append(0)
sm = 0
costs = []
pre = 0
for x, y in zip(a, b):
    z = (y - x) % m
    v = (z - pre) % m
    sm += v
    costs.append(m - v)
    pre = z
cnt = sm // m
costs.sort()
ans = sum(costs[:cnt])
print(ans)
0