結果

問題 No.1767 BLUE to RED
ユーザー hir355hir355
提出日時 2021-11-26 23:06:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 377 bytes
コンパイル時間 965 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 139,868 KB
最終ジャッジ日時 2023-09-12 05:31:04
合計ジャッジ時間 7,743 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,216 KB
testcase_01 AC 76 ms
71,160 KB
testcase_02 AC 78 ms
71,148 KB
testcase_03 AC 77 ms
71,232 KB
testcase_04 AC 82 ms
75,136 KB
testcase_05 AC 85 ms
75,572 KB
testcase_06 AC 82 ms
75,156 KB
testcase_07 AC 91 ms
76,412 KB
testcase_08 AC 94 ms
76,672 KB
testcase_09 AC 217 ms
99,172 KB
testcase_10 AC 260 ms
103,420 KB
testcase_11 AC 215 ms
103,816 KB
testcase_12 AC 214 ms
98,868 KB
testcase_13 AC 288 ms
124,372 KB
testcase_14 AC 319 ms
139,772 KB
testcase_15 AC 315 ms
139,640 KB
testcase_16 AC 321 ms
139,640 KB
testcase_17 AC 317 ms
139,440 KB
testcase_18 AC 319 ms
139,672 KB
testcase_19 AC 318 ms
139,592 KB
testcase_20 AC 318 ms
139,544 KB
testcase_21 AC 316 ms
139,572 KB
testcase_22 AC 320 ms
139,592 KB
testcase_23 AC 319 ms
139,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
m, n = map(int, input().split())
b = list(map(int, input().split()))
a = list(map(int, input().split()))
c = a + b
c.sort()
ans = max(c) - min(c) + 1 - m
for i in range(m - 1):
    l = bisect_left(c, b[i])
    r = bisect_left(c, b[i + 1])
    res = 0
    for j in range(l, r):
        res = max(res, c[j + 1] - c[j] - 1)
    ans -= res
print(ans)
0