結果

問題 No.808 Kaiten Sushi?
ユーザー tktk_snsntktk_snsn
提出日時 2021-02-06 12:00:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 933 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 111,488 KB
最終ジャッジ日時 2023-09-15 16:26:35
合計ジャッジ時間 8,914 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
70,972 KB
testcase_01 AC 70 ms
71,300 KB
testcase_02 AC 69 ms
71,136 KB
testcase_03 AC 71 ms
71,124 KB
testcase_04 AC 72 ms
71,120 KB
testcase_05 AC 72 ms
71,120 KB
testcase_06 AC 71 ms
71,248 KB
testcase_07 AC 81 ms
76,728 KB
testcase_08 AC 81 ms
76,680 KB
testcase_09 AC 82 ms
76,360 KB
testcase_10 AC 86 ms
76,700 KB
testcase_11 AC 82 ms
76,592 KB
testcase_12 AC 82 ms
76,808 KB
testcase_13 AC 85 ms
76,788 KB
testcase_14 AC 79 ms
76,616 KB
testcase_15 AC 84 ms
76,596 KB
testcase_16 AC 85 ms
76,752 KB
testcase_17 AC 76 ms
76,424 KB
testcase_18 AC 77 ms
75,284 KB
testcase_19 AC 73 ms
71,500 KB
testcase_20 AC 73 ms
75,272 KB
testcase_21 AC 74 ms
75,232 KB
testcase_22 AC 74 ms
75,228 KB
testcase_23 AC 104 ms
91,636 KB
testcase_24 AC 100 ms
87,788 KB
testcase_25 AC 98 ms
90,188 KB
testcase_26 AC 95 ms
88,772 KB
testcase_27 AC 129 ms
102,716 KB
testcase_28 AC 93 ms
84,488 KB
testcase_29 AC 127 ms
100,840 KB
testcase_30 AC 106 ms
91,568 KB
testcase_31 AC 131 ms
104,832 KB
testcase_32 AC 146 ms
111,036 KB
testcase_33 AC 114 ms
89,600 KB
testcase_34 AC 121 ms
93,968 KB
testcase_35 AC 131 ms
98,640 KB
testcase_36 AC 114 ms
89,876 KB
testcase_37 AC 73 ms
71,344 KB
testcase_38 AC 72 ms
71,300 KB
testcase_39 AC 144 ms
107,156 KB
testcase_40 AC 101 ms
83,044 KB
testcase_41 AC 103 ms
84,452 KB
testcase_42 AC 138 ms
101,024 KB
testcase_43 AC 109 ms
89,232 KB
testcase_44 AC 117 ms
93,888 KB
testcase_45 AC 108 ms
88,808 KB
testcase_46 AC 98 ms
81,684 KB
testcase_47 AC 151 ms
111,484 KB
testcase_48 AC 147 ms
111,488 KB
testcase_49 AC 146 ms
111,400 KB
testcase_50 AC 147 ms
111,428 KB
testcase_51 AC 148 ms
111,408 KB
testcase_52 AC 116 ms
97,528 KB
testcase_53 AC 134 ms
109,600 KB
testcase_54 AC 70 ms
71,132 KB
testcase_55 AC 70 ms
71,440 KB
testcase_56 AC 70 ms
71,136 KB
testcase_57 AC 102 ms
89,684 KB
testcase_58 AC 111 ms
94,528 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