結果

問題 No.1767 BLUE to RED
ユーザー titiatitia
提出日時 2021-11-26 23:00:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 647 ms / 2,000 ms
コード長 523 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 42,120 KB
最終ジャッジ日時 2023-09-12 05:25:49
合計ジャッジ時間 10,295 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,928 KB
testcase_01 AC 16 ms
7,848 KB
testcase_02 AC 16 ms
7,912 KB
testcase_03 AC 17 ms
8,032 KB
testcase_04 AC 17 ms
8,036 KB
testcase_05 AC 17 ms
7,968 KB
testcase_06 AC 16 ms
7,848 KB
testcase_07 AC 18 ms
7,964 KB
testcase_08 AC 18 ms
8,036 KB
testcase_09 AC 352 ms
27,280 KB
testcase_10 AC 441 ms
34,080 KB
testcase_11 AC 390 ms
28,556 KB
testcase_12 AC 347 ms
27,224 KB
testcase_13 AC 487 ms
37,296 KB
testcase_14 AC 626 ms
41,916 KB
testcase_15 AC 637 ms
42,020 KB
testcase_16 AC 637 ms
41,992 KB
testcase_17 AC 632 ms
41,988 KB
testcase_18 AC 643 ms
42,080 KB
testcase_19 AC 647 ms
41,992 KB
testcase_20 AC 639 ms
42,048 KB
testcase_21 AC 636 ms
42,120 KB
testcase_22 AC 637 ms
42,004 KB
testcase_23 AC 639 ms
42,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
import bisect

N,M=map(int,input().split())
A=[-1<<60]+list(map(int,input().split()))+[1<<60]
B=list(map(int,input().split()))

X=[[] for i in range(len(A))]

for b in B:
    x=bisect.bisect(A,b)
    X[x-1].append(b)

#print(X)

ANS=0

for i in range(len(A)-1):
    if X[i]==[]:
        continue

    else:
        X2=[A[i]]+X[i]+[A[i+1]]

        P=X2[-1]-X2[0]

        MAX=-1
        for i in range(len(X2)-1):
            MAX=max(MAX,X2[i+1]-X2[i])

        ANS+=P-MAX

print(ANS)
0