結果

問題 No.1449 新プロランド
ユーザー mkawa2mkawa2
提出日時 2021-03-31 15:32:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 1,211 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 30,856 KB
最終ジャッジ日時 2023-08-25 16:48:56
合計ジャッジ時間 2,810 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,684 KB
testcase_01 AC 19 ms
9,164 KB
testcase_02 AC 21 ms
9,616 KB
testcase_03 AC 20 ms
9,112 KB
testcase_04 AC 19 ms
9,124 KB
testcase_05 AC 116 ms
29,016 KB
testcase_06 AC 50 ms
21,556 KB
testcase_07 AC 52 ms
22,100 KB
testcase_08 AC 88 ms
29,676 KB
testcase_09 AC 27 ms
12,604 KB
testcase_10 AC 61 ms
26,312 KB
testcase_11 AC 67 ms
28,440 KB
testcase_12 AC 110 ms
26,580 KB
testcase_13 AC 35 ms
15,224 KB
testcase_14 AC 69 ms
29,248 KB
testcase_15 AC 54 ms
23,420 KB
testcase_16 AC 39 ms
16,816 KB
testcase_17 AC 61 ms
21,356 KB
testcase_18 AC 19 ms
8,948 KB
testcase_19 AC 55 ms
23,848 KB
testcase_20 AC 18 ms
8,608 KB
testcase_21 AC 52 ms
22,084 KB
testcase_22 AC 21 ms
9,892 KB
testcase_23 AC 65 ms
27,628 KB
testcase_24 AC 26 ms
11,712 KB
testcase_25 AC 24 ms
11,048 KB
testcase_26 AC 18 ms
8,960 KB
testcase_27 AC 196 ms
30,856 KB
testcase_28 AC 53 ms
15,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

from heapq import *

n,m=LI()
to=[[] for _ in range(n)]
for _ in range(m):
    u,v,c=LI()
    u,v=u-1,v-1
    to[u].append((v,c))
    to[v].append((u,c))
tt=LI()

mx=30000
dist=[[inf]*mx for _ in range(n)]
dist[0][0]=0
hp=[(0,0,0)]
while hp:
    d,u,p=heappop(hp)
    if u==n-1:
        print(d)
        break
    if d>dist[u][p]:continue
    p+=tt[u]
    if p>=mx:continue
    for v,c in to[u]:
        nd=d+tt[u]+c//p
        if dist[v][p]<=nd:continue
        dist[v][p]=nd
        heappush(hp,(nd,v,p))
0