結果

問題 No.2603 Tone Correction
ユーザー ニックネーム
提出日時 2024-01-13 02:18:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 230 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 82,180 KB
実行使用メモリ 157,888 KB
最終ジャッジ日時 2024-09-28 01:09:32
合計ジャッジ時間 7,191 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
a = [0]+list(map(int,input().split()))+[0]
b = [0]+list(map(int,input().split()))+[0]
d = sorted((b[i+1]-a[i+1]-b[i]+a[i])%m for i in range(n+1))
c = sum(d)//m
print((sum(d[:-c])+c*m-sum(d[-c:]))//2)
0