結果

問題 No.1767 BLUE to RED
ユーザー tktk_snsntktk_snsn
提出日時 2021-11-26 22:49:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 544 ms / 2,000 ms
コード長 492 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,976 KB
実行使用メモリ 40,616 KB
最終ジャッジ日時 2023-09-12 05:20:04
合計ジャッジ時間 8,997 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,932 KB
testcase_01 AC 17 ms
7,760 KB
testcase_02 AC 16 ms
7,840 KB
testcase_03 AC 16 ms
7,788 KB
testcase_04 AC 17 ms
8,404 KB
testcase_05 AC 17 ms
7,792 KB
testcase_06 AC 17 ms
7,832 KB
testcase_07 AC 17 ms
8,272 KB
testcase_08 AC 18 ms
8,400 KB
testcase_09 AC 307 ms
26,188 KB
testcase_10 AC 399 ms
30,180 KB
testcase_11 AC 335 ms
27,804 KB
testcase_12 AC 306 ms
25,200 KB
testcase_13 AC 436 ms
31,476 KB
testcase_14 AC 542 ms
40,588 KB
testcase_15 AC 534 ms
40,616 KB
testcase_16 AC 538 ms
40,524 KB
testcase_17 AC 540 ms
40,588 KB
testcase_18 AC 539 ms
40,548 KB
testcase_19 AC 544 ms
40,576 KB
testcase_20 AC 533 ms
40,520 KB
testcase_21 AC 536 ms
40,556 KB
testcase_22 AC 535 ms
40,508 KB
testcase_23 AC 538 ms
40,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def F(L, R, B):
    if not B:
        return 0
    BL = [0] + [b - L for b in B]
    BR = [R - b for b in B] + [0]
    return min(l + r for l, r in zip(BL, BR))


inf = 10 ** 18
N, M = map(int, input().split())
A = [-inf] + list(map(int, input().split())) + [inf]
B = list(map(int, input().split())) + [inf + 10]

ans = 0
j = 0
for i in range(N+1):
    L = A[i]
    R = A[i+1]
    blue = []
    while L < B[j] < R:
        blue.append(B[j])
        j += 1
    ans += F(L, R, blue)

print(ans)
0