結果

問題 No.1767 BLUE to RED
ユーザー first_vilfirst_vil
提出日時 2021-11-05 11:16:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 239 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 847 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 128,752 KB
最終ジャッジ日時 2023-09-12 05:00:52
合計ジャッジ時間 6,673 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,848 KB
testcase_01 AC 93 ms
71,592 KB
testcase_02 AC 91 ms
71,580 KB
testcase_03 AC 91 ms
71,720 KB
testcase_04 AC 91 ms
71,872 KB
testcase_05 AC 91 ms
71,444 KB
testcase_06 AC 91 ms
71,752 KB
testcase_07 AC 97 ms
77,544 KB
testcase_08 AC 100 ms
77,372 KB
testcase_09 AC 187 ms
111,272 KB
testcase_10 AC 219 ms
125,996 KB
testcase_11 AC 199 ms
117,360 KB
testcase_12 AC 193 ms
111,228 KB
testcase_13 AC 221 ms
127,932 KB
testcase_14 AC 238 ms
120,440 KB
testcase_15 AC 234 ms
128,752 KB
testcase_16 AC 235 ms
122,308 KB
testcase_17 AC 239 ms
120,448 KB
testcase_18 AC 237 ms
124,424 KB
testcase_19 AC 236 ms
124,744 KB
testcase_20 AC 235 ms
128,712 KB
testcase_21 AC 234 ms
128,604 KB
testcase_22 AC 232 ms
123,656 KB
testcase_23 AC 233 ms
128,748 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