結果

問題 No.1104 オンライン点呼
ユーザー maspymaspy
提出日時 2020-07-03 23:12:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 596 ms / 2,000 ms
コード長 742 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 24,856 KB
最終ジャッジ日時 2023-10-17 06:13:40
合計ジャッジ時間 6,054 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,180 KB
testcase_01 AC 303 ms
24,412 KB
testcase_02 AC 297 ms
24,412 KB
testcase_03 AC 284 ms
20,188 KB
testcase_04 AC 30 ms
10,180 KB
testcase_05 AC 29 ms
10,180 KB
testcase_06 AC 30 ms
10,180 KB
testcase_07 AC 184 ms
15,516 KB
testcase_08 AC 91 ms
12,332 KB
testcase_09 AC 596 ms
24,856 KB
testcase_10 AC 30 ms
10,180 KB
testcase_11 AC 134 ms
15,380 KB
testcase_12 AC 190 ms
17,920 KB
testcase_13 AC 121 ms
14,996 KB
testcase_14 AC 36 ms
10,512 KB
testcase_15 AC 206 ms
19,100 KB
testcase_16 AC 275 ms
21,792 KB
testcase_17 AC 160 ms
16,732 KB
testcase_18 AC 207 ms
18,836 KB
testcase_19 AC 253 ms
21,700 KB
testcase_20 AC 266 ms
22,548 KB
testcase_21 AC 271 ms
22,616 KB
testcase_22 AC 232 ms
20,448 KB
testcase_23 AC 183 ms
18,236 KB
testcase_24 AC 96 ms
13,508 KB
testcase_25 AC 30 ms
10,180 KB
testcase_26 AC 31 ms
10,180 KB
testcase_27 AC 31 ms
10,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from heapq import heappush, heappop

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
A = [0] + list(map(int, readline().split()))
B = [0] + list(map(int, readline().split()))

if N == 1:
    print(0)
    exit()

q = [(0, 1)]
done = [0] * (N + 1)
done[1] = 0
ans = 0
while q:
    t, j = heappop(q)
    if done[j]:
        continue
    if j in (N - 1, N):
        ans = max(ans, t)
    done[j] = 1
    # j+1 への伝搬
    if j < N:
        t1, j1 = t + A[j] + B[j + 1], j + 1
        heappush(q, (t1, j1))
    # j+2 への伝搬
    if j < N - 1:
        t1, j1 = t + A[j] + B[j + 2] + K, j + 2
        heappush(q, (t1, j1))

print(ans)
0