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