結果

問題 No.1767 BLUE to RED
ユーザー Eki1009Eki1009
提出日時 2021-11-26 22:56:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 258 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 143,428 KB
最終ジャッジ日時 2023-09-12 05:23:22
合計ジャッジ時間 6,237 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,420 KB
testcase_01 AC 77 ms
71,388 KB
testcase_02 AC 78 ms
71,196 KB
testcase_03 AC 76 ms
71,312 KB
testcase_04 AC 78 ms
71,056 KB
testcase_05 AC 80 ms
71,176 KB
testcase_06 AC 78 ms
71,208 KB
testcase_07 AC 99 ms
76,288 KB
testcase_08 AC 90 ms
76,312 KB
testcase_09 AC 186 ms
99,296 KB
testcase_10 AC 216 ms
106,168 KB
testcase_11 AC 181 ms
101,684 KB
testcase_12 AC 183 ms
99,500 KB
testcase_13 AC 234 ms
129,844 KB
testcase_14 AC 255 ms
143,096 KB
testcase_15 AC 250 ms
143,176 KB
testcase_16 AC 248 ms
143,356 KB
testcase_17 AC 248 ms
143,296 KB
testcase_18 AC 252 ms
143,216 KB
testcase_19 AC 246 ms
143,428 KB
testcase_20 AC 250 ms
142,940 KB
testcase_21 AC 244 ms
143,068 KB
testcase_22 AC 258 ms
143,104 KB
testcase_23 AC 245 ms
142,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
A = [-10**20]+list(map(int,input().split()))+[10**20]
B = list(map(int,input().split()))
j = 0
ans = 0
for i in range(n+1):
    l,r = A[i],A[i+1]
    C = [A[i]]
    while j < m and B[j] < r:
        C.append(B[j])
        j += 1
    C.append(A[i+1])
    z = max(C[k+1]-C[k] for k in range(len(C)-1))
    ans += (C[-1]-C[0])-z
print(ans)
0