結果

問題 No.2603 Tone Correction
ユーザー 👑 rin204rin204
提出日時 2024-01-12 21:44:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 361 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 162,100 KB
最終ジャッジ日時 2024-01-12 21:45:08
合計ジャッジ時間 7,190 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 52 ms
64,444 KB
testcase_04 AC 51 ms
64,444 KB
testcase_05 AC 49 ms
64,444 KB
testcase_06 AC 48 ms
64,444 KB
testcase_07 AC 48 ms
64,444 KB
testcase_08 AC 48 ms
64,444 KB
testcase_09 AC 48 ms
64,444 KB
testcase_10 AC 48 ms
64,444 KB
testcase_11 AC 48 ms
64,444 KB
testcase_12 AC 49 ms
64,444 KB
testcase_13 AC 204 ms
161,512 KB
testcase_14 AC 202 ms
161,512 KB
testcase_15 AC 204 ms
161,848 KB
testcase_16 AC 201 ms
161,592 KB
testcase_17 AC 204 ms
161,972 KB
testcase_18 AC 201 ms
161,640 KB
testcase_19 AC 201 ms
161,844 KB
testcase_20 AC 201 ms
161,720 KB
testcase_21 AC 200 ms
161,848 KB
testcase_22 AC 203 ms
162,100 KB
testcase_23 AC 186 ms
140,368 KB
testcase_24 AC 182 ms
140,368 KB
testcase_25 AC 180 ms
140,496 KB
testcase_26 AC 179 ms
140,368 KB
testcase_27 AC 180 ms
140,752 KB
testcase_28 AC 182 ms
140,112 KB
testcase_29 AC 183 ms
140,112 KB
testcase_30 AC 185 ms
140,112 KB
testcase_31 AC 185 ms
140,108 KB
testcase_32 AC 182 ms
140,112 KB
testcase_33 AC 36 ms
53,460 KB
testcase_34 AC 163 ms
160,136 KB
testcase_35 AC 163 ms
160,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [(a - b) % m for a, b in zip(A, B)]
b = 0
D = []
for c in C:
    D.append((c - b) % m)
    b = c
D.append((-b) % m)
D.sort()
tot = sum(D)
tot2 = 0
ans = tot
for d in D[::-1]:
    tot2 += m - d
    tot -= d
    ans = min(ans, max(tot, tot2))
print(ans)
0