結果
問題 | No.2603 Tone Correction |
ユーザー |
👑 |
提出日時 | 2024-01-12 21:44:58 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 191 ms / 2,000 ms |
コード長 | 361 bytes |
コンパイル時間 | 300 ms |
コンパイル使用メモリ | 82,116 KB |
実行使用メモリ | 162,444 KB |
最終ジャッジ日時 | 2024-09-27 21:46:21 |
合計ジャッジ時間 | 6,448 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
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 = 0D = []for c in C:D.append((c - b) % m)b = cD.append((-b) % m)D.sort()tot = sum(D)tot2 = 0ans = totfor d in D[::-1]:tot2 += m - dtot -= dans = min(ans, max(tot, tot2))print(ans)