結果

問題 No.1449 新プロランド
ユーザー mkawa2mkawa2
提出日時 2021-03-31 15:29:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 1,211 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 16,528 KB
最終ジャッジ日時 2023-08-25 16:48:37
合計ジャッジ時間 2,150 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,356 KB
testcase_01 AC 17 ms
8,716 KB
testcase_02 AC 18 ms
8,688 KB
testcase_03 AC 18 ms
8,572 KB
testcase_04 AC 17 ms
8,604 KB
testcase_05 AC 60 ms
15,456 KB
testcase_06 AC 28 ms
12,788 KB
testcase_07 AC 28 ms
12,872 KB
testcase_08 AC 40 ms
15,372 KB
testcase_09 AC 20 ms
9,712 KB
testcase_10 AC 31 ms
14,332 KB
testcase_11 AC 32 ms
15,104 KB
testcase_12 AC 60 ms
14,796 KB
testcase_13 AC 22 ms
10,604 KB
testcase_14 AC 34 ms
15,208 KB
testcase_15 AC 29 ms
13,260 KB
testcase_16 AC 24 ms
11,184 KB
testcase_17 AC 33 ms
12,724 KB
testcase_18 AC 17 ms
8,640 KB
testcase_19 AC 29 ms
13,552 KB
testcase_20 AC 18 ms
8,616 KB
testcase_21 AC 28 ms
12,936 KB
testcase_22 AC 18 ms
8,876 KB
testcase_23 AC 33 ms
14,712 KB
testcase_24 AC 19 ms
9,588 KB
testcase_25 AC 19 ms
9,284 KB
testcase_26 AC 17 ms
8,556 KB
testcase_27 AC 136 ms
16,528 KB
testcase_28 AC 33 ms
11,040 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=10000
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