結果

問題 No.1767 BLUE to RED
ユーザー 👑 tamatotamato
提出日時 2021-11-26 22:35:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 959 ms
コンパイル使用メモリ 87,724 KB
実行使用メモリ 148,536 KB
最終ジャッジ日時 2023-09-12 05:13:32
合計ジャッジ時間 7,297 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,748 KB
testcase_01 AC 70 ms
71,596 KB
testcase_02 AC 71 ms
71,504 KB
testcase_03 AC 70 ms
71,648 KB
testcase_04 AC 70 ms
71,508 KB
testcase_05 AC 71 ms
71,648 KB
testcase_06 AC 71 ms
71,496 KB
testcase_07 AC 79 ms
76,888 KB
testcase_08 AC 83 ms
77,124 KB
testcase_09 AC 189 ms
119,540 KB
testcase_10 AC 226 ms
127,424 KB
testcase_11 AC 209 ms
130,580 KB
testcase_12 AC 192 ms
119,476 KB
testcase_13 AC 243 ms
148,536 KB
testcase_14 AC 273 ms
142,680 KB
testcase_15 AC 273 ms
142,876 KB
testcase_16 AC 275 ms
142,860 KB
testcase_17 AC 272 ms
142,924 KB
testcase_18 AC 274 ms
142,808 KB
testcase_19 AC 273 ms
142,948 KB
testcase_20 AC 273 ms
142,884 KB
testcase_21 AC 276 ms
142,900 KB
testcase_22 AC 276 ms
142,944 KB
testcase_23 AC 272 ms
142,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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


    A.append(10 ** 10)
    C = []
    for a in A:
        C.append((a, 0))
    for b in B:
        C.append((b, 1))
    C.sort(key=lambda x: x[0])
    ans = 0
    st = [-10 ** 10]
    for x, y in C:
        if y == 0:
            st.append(x)
            ans += st[-1] - st[0] - 1
            ma = 0
            for i in range(len(st) - 1):
                ma = max(ma, st[i+1] - st[i] - 1)
            ans -= ma
            st = [x]
        else:
            st.append(x)
    print(ans)


if __name__ == '__main__':
    main()
0