結果

問題 No.808 Kaiten Sushi?
ユーザー tktk_snsntktk_snsn
提出日時 2021-02-06 11:58:49
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 782 bytes
コンパイル時間 403 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 111,196 KB
最終ジャッジ日時 2023-09-15 16:25:43
合計ジャッジ時間 10,061 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,356 KB
testcase_01 AC 70 ms
71,464 KB
testcase_02 AC 71 ms
71,272 KB
testcase_03 AC 71 ms
71,228 KB
testcase_04 AC 70 ms
71,128 KB
testcase_05 AC 70 ms
71,172 KB
testcase_06 AC 70 ms
71,532 KB
testcase_07 AC 84 ms
76,664 KB
testcase_08 AC 83 ms
76,408 KB
testcase_09 AC 82 ms
76,620 KB
testcase_10 AC 85 ms
76,828 KB
testcase_11 AC 85 ms
76,728 KB
testcase_12 AC 86 ms
76,564 KB
testcase_13 AC 85 ms
76,656 KB
testcase_14 AC 79 ms
76,616 KB
testcase_15 AC 84 ms
76,412 KB
testcase_16 AC 86 ms
76,708 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 75 ms
75,104 KB
testcase_21 AC 73 ms
74,800 KB
testcase_22 AC 74 ms
75,148 KB
testcase_23 AC 102 ms
90,964 KB
testcase_24 AC 98 ms
86,884 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 AC 146 ms
109,596 KB
testcase_33 AC 114 ms
88,784 KB
testcase_34 AC 119 ms
92,764 KB
testcase_35 AC 124 ms
95,096 KB
testcase_36 AC 122 ms
88,968 KB
testcase_37 RE -
testcase_38 RE -
testcase_39 AC 140 ms
105,316 KB
testcase_40 AC 100 ms
82,676 KB
testcase_41 AC 102 ms
84,144 KB
testcase_42 AC 133 ms
99,856 KB
testcase_43 AC 113 ms
88,680 KB
testcase_44 AC 120 ms
92,952 KB
testcase_45 AC 111 ms
88,704 KB
testcase_46 AC 103 ms
81,596 KB
testcase_47 AC 147 ms
109,912 KB
testcase_48 AC 145 ms
110,040 KB
testcase_49 AC 141 ms
109,828 KB
testcase_50 AC 146 ms
110,032 KB
testcase_51 AC 145 ms
110,060 KB
testcase_52 RE -
testcase_53 RE -
testcase_54 AC 69 ms
71,440 KB
testcase_55 AC 70 ms
71,532 KB
testcase_56 AC 71 ms
71,392 KB
testcase_57 AC 103 ms
89,120 KB
testcase_58 AC 112 ms
93,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def merge(x, y):
    x.reverse()
    y.reverse()
    res = []
    while x and y:
        if x[-1] < y[-1]:
            res.append(x.pop())
        else:
            res.append(~y.pop())
    while x:
        res.append(x.pop())
    while y:
        res.append(~y.pop())
    return res


N, L = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = merge(A, B)

p = 0
D = [-1] * (2 * N)
for i, c in enumerate(C):
    if c >= 0:
        p += 1
    else:
        p -= 1
    D[i] = p

mx = max(D)
mn = min(D)

if mx == 0:
    ans = L * (mx - mn) + B[0]
else:
    D = [d - mn for d in D]
    loop = max(D) - 1
    walk = -1
    for c, d in zip(C, D):
        if c < 0 and d == loop:
            walk = ~c
    ans = L*loop + walk

print(ans)
0