結果
問題 |
No.1104 オンライン点呼
|
ユーザー |
![]() |
提出日時 | 2020-07-03 23:11:21 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 714 bytes |
コンパイル時間 | 85 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 25,540 KB |
最終ジャッジ日時 | 2024-09-17 04:51:21 |
合計ジャッジ時間 | 5,853 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 WA * 1 |
ソースコード
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)