結果

問題 No.2603 Tone Correction
ユーザー ShirotsumeShirotsume
提出日時 2024-01-12 23:57:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 682 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 281,608 KB
最終ジャッジ日時 2024-01-12 23:57:53
合計ジャッジ時間 18,234 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 177 ms
95,904 KB
testcase_01 AC 175 ms
89,100 KB
testcase_02 AC 182 ms
89,484 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import fractions
import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

n, m = mi()

a = li()
b = li()
c = [0]
for i in range(n):
    c.append(min((b[i] - a[i]), (b[i] + a[i]) % m))
c.append(0)
n = len(c)

dp = [[inf] * 101 for _ in range(n + 1)]
dp[0][0] = 0
for i in range(n - 1):
    for j in range(-50, 51):
        for k in range(-50, 51):
            dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + abs(c[i] + m * (j - 5) - (c[i + 1] + m * (k - 5))))
print(dp[n - 1][0] // 2)
            
0