結果

問題 No.2603 Tone Correction
ユーザー titiatitia
提出日時 2024-01-13 01:03:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 446 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 11,776 KB
実行使用メモリ 42,500 KB
最終ジャッジ日時 2024-01-13 01:03:42
合計ジャッジ時間 11,872 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,112 KB
testcase_01 AC 27 ms
10,112 KB
testcase_02 AC 28 ms
10,112 KB
testcase_03 AC 33 ms
10,496 KB
testcase_04 AC 33 ms
10,496 KB
testcase_05 AC 33 ms
10,496 KB
testcase_06 AC 33 ms
10,496 KB
testcase_07 AC 33 ms
10,496 KB
testcase_08 AC 33 ms
10,496 KB
testcase_09 AC 33 ms
10,496 KB
testcase_10 AC 32 ms
10,496 KB
testcase_11 AC 33 ms
10,496 KB
testcase_12 AC 32 ms
10,496 KB
testcase_13 AC 411 ms
40,580 KB
testcase_14 AC 423 ms
42,500 KB
testcase_15 AC 409 ms
42,500 KB
testcase_16 AC 428 ms
40,580 KB
testcase_17 AC 417 ms
42,500 KB
testcase_18 AC 411 ms
40,580 KB
testcase_19 AC 446 ms
40,580 KB
testcase_20 AC 405 ms
40,580 KB
testcase_21 AC 425 ms
42,500 KB
testcase_22 AC 430 ms
42,500 KB
testcase_23 AC 430 ms
35,204 KB
testcase_24 AC 401 ms
35,204 KB
testcase_25 AC 406 ms
35,204 KB
testcase_26 AC 395 ms
35,204 KB
testcase_27 AC 404 ms
35,204 KB
testcase_28 AC 422 ms
35,568 KB
testcase_29 AC 399 ms
35,204 KB
testcase_30 AC 411 ms
35,204 KB
testcase_31 AC 416 ms
35,204 KB
testcase_32 AC 401 ms
35,204 KB
testcase_33 AC 28 ms
10,112 KB
testcase_34 AC 303 ms
40,728 KB
testcase_35 AC 298 ms
40,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,mod=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

for i in range(N):
    A[i]=(A[i]-B[i])%mod

A=[0]+A+[0]

S=[]
for i in range(1,len(A)):
    S.append((A[i]-A[i-1]))

SUM=0
for s in S:
    if s>=0:
        SUM+=s

S.sort(reverse=True)

for i in range(len(S)):
    if S[i]>S[-1-i]+mod:
        SUM=SUM-S[i]+S[-1-i]+mod

print(SUM)
0