結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,164 KB
testcase_01 AC 315 ms
24,404 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 29 ms
10,164 KB
testcase_05 AC 29 ms
10,164 KB
testcase_06 AC 30 ms
10,164 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 604 ms
24,848 KB
testcase_10 AC 30 ms
10,164 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 212 ms
19,092 KB
testcase_16 WA -
testcase_17 AC 169 ms
16,724 KB
testcase_18 AC 216 ms
18,828 KB
testcase_19 AC 264 ms
21,692 KB
testcase_20 AC 277 ms
22,540 KB
testcase_21 AC 284 ms
22,608 KB
testcase_22 AC 237 ms
20,440 KB
testcase_23 AC 189 ms
18,228 KB
testcase_24 AC 102 ms
13,500 KB
testcase_25 AC 29 ms
10,164 KB
testcase_26 AC 30 ms
10,164 KB
testcase_27 AC 29 ms
10,164 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 = [(A[1] + B[2], 2)]
done = [0] * (N + 1)
done[1] = 1
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