結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,176 KB
testcase_01 AC 309 ms
24,408 KB
testcase_02 AC 302 ms
24,408 KB
testcase_03 AC 290 ms
20,184 KB
testcase_04 AC 30 ms
10,176 KB
testcase_05 AC 30 ms
10,176 KB
testcase_06 AC 31 ms
10,176 KB
testcase_07 AC 192 ms
15,512 KB
testcase_08 AC 95 ms
12,328 KB
testcase_09 AC 606 ms
24,852 KB
testcase_10 AC 29 ms
10,176 KB
testcase_11 AC 137 ms
15,376 KB
testcase_12 AC 199 ms
17,916 KB
testcase_13 AC 127 ms
14,992 KB
testcase_14 AC 37 ms
10,508 KB
testcase_15 AC 213 ms
19,096 KB
testcase_16 WA -
testcase_17 AC 172 ms
16,728 KB
testcase_18 AC 217 ms
18,832 KB
testcase_19 AC 258 ms
21,696 KB
testcase_20 AC 280 ms
22,544 KB
testcase_21 AC 284 ms
22,612 KB
testcase_22 AC 239 ms
20,444 KB
testcase_23 AC 187 ms
18,232 KB
testcase_24 AC 102 ms
13,504 KB
testcase_25 AC 30 ms
10,176 KB
testcase_26 AC 30 ms
10,176 KB
testcase_27 AC 30 ms
10,176 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
    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