結果

問題 No.1767 BLUE to RED
ユーザー first_vilfirst_vil
提出日時 2021-11-05 11:16:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 570 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 467 ms
コンパイル使用メモリ 10,768 KB
実行使用メモリ 40,960 KB
最終ジャッジ日時 2023-09-12 05:01:02
合計ジャッジ時間 9,675 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,444 KB
testcase_01 AC 18 ms
8,440 KB
testcase_02 AC 18 ms
8,556 KB
testcase_03 AC 18 ms
8,520 KB
testcase_04 AC 19 ms
8,664 KB
testcase_05 AC 19 ms
8,624 KB
testcase_06 AC 19 ms
8,548 KB
testcase_07 AC 20 ms
8,572 KB
testcase_08 AC 20 ms
8,744 KB
testcase_09 AC 319 ms
25,440 KB
testcase_10 AC 414 ms
30,688 KB
testcase_11 AC 356 ms
28,828 KB
testcase_12 AC 323 ms
25,324 KB
testcase_13 AC 449 ms
32,016 KB
testcase_14 AC 558 ms
38,744 KB
testcase_15 AC 556 ms
38,680 KB
testcase_16 AC 562 ms
38,676 KB
testcase_17 AC 561 ms
38,684 KB
testcase_18 AC 563 ms
38,788 KB
testcase_19 AC 570 ms
38,816 KB
testcase_20 AC 560 ms
38,648 KB
testcase_21 AC 568 ms
40,960 KB
testcase_22 AC 560 ms
38,692 KB
testcase_23 AC 565 ms
38,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque
input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

n,m = mi()
a = deque(li())
x = []
for b in li():
    while a and a[0]<b:
        x.append(a.popleft())
    x.append(-b)
x += list(a)

ans = abs(x[-1]) - abs(x[0])
pre = -1
mac = 0;
for i in range(n+m):
    if i:
        mac = max(mac, abs(x[i]) - abs(x[i - 1]))
    if x[i] > 0:
        if pre != -1:
            ans -= mac
        pre = i
        mac = 0

print(ans)
0