結果

問題 No.1767 BLUE to RED
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-11-27 09:30:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 742 bytes
コンパイル時間 1,067 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 143,076 KB
最終ジャッジ日時 2023-09-12 12:58:43
合計ジャッジ時間 9,504 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,280 KB
testcase_01 AC 72 ms
71,132 KB
testcase_02 AC 72 ms
71,432 KB
testcase_03 AC 71 ms
71,448 KB
testcase_04 WA -
testcase_05 AC 74 ms
71,440 KB
testcase_06 AC 74 ms
71,508 KB
testcase_07 AC 77 ms
76,248 KB
testcase_08 AC 81 ms
76,516 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 251 ms
125,012 KB
testcase_13 AC 320 ms
141,740 KB
testcase_14 AC 395 ms
142,696 KB
testcase_15 WA -
testcase_16 AC 331 ms
142,792 KB
testcase_17 AC 332 ms
142,764 KB
testcase_18 AC 330 ms
142,664 KB
testcase_19 WA -
testcase_20 AC 338 ms
142,640 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 330 ms
142,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
a = [-(10**9 + 1)] + list(map(int,input().split())) + [10**9 + 1] 
b = list(map(int,input().split()))
d = {}
ab = []
for i in range(n+2):
    ab.append([a[i],1])
for i in range(m):
    ab.append([b[i],0])
ab.sort()
flg = 1
max_ = 0
sum_ = 0
idx_blue = 0
ans = 0
for i in range(n+m+2):
    idx,color = ab[i]
    if color == 1 and flg == 0:
        max_ = max(ab[i][0] - ab[i-1][0] ,max_)
        sum_ += ab[i][0] - ab[i-1][0]
        ans += sum_ - max_
    elif color == 0 and flg == 1:
        max_ = ab[i][0] - ab[i-1][0]
        sum_ = ab[i][0] - ab[i-1][0]
    elif color == 0 and flg == 0:
        max_ = max(ab[i][0] - ab[i-1][0] ,max_)
        sum_ += ab[i][0] - ab[i-1][0]
    flg = color
    
print(ans)
0