結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
9,852 KB
testcase_01 AC 24 ms
11,364 KB
testcase_02 AC 28 ms
12,788 KB
testcase_03 AC 24 ms
11,328 KB
testcase_04 AC 24 ms
11,260 KB
testcase_05 AC 299 ms
75,580 KB
testcase_06 AC 128 ms
52,088 KB
testcase_07 AC 128 ms
54,616 KB
testcase_08 AC 248 ms
79,176 KB
testcase_09 AC 51 ms
22,260 KB
testcase_10 AC 161 ms
67,736 KB
testcase_11 AC 182 ms
74,948 KB
testcase_12 AC 276 ms
67,556 KB
testcase_13 AC 73 ms
31,060 KB
testcase_14 AC 189 ms
78,120 KB
testcase_15 AC 140 ms
58,468 KB
testcase_16 AC 87 ms
36,520 KB
testcase_17 AC 156 ms
50,796 KB
testcase_18 AC 23 ms
10,836 KB
testcase_19 AC 143 ms
60,008 KB
testcase_20 AC 21 ms
9,848 KB
testcase_21 AC 132 ms
54,468 KB
testcase_22 AC 31 ms
13,592 KB
testcase_23 AC 176 ms
72,456 KB
testcase_24 AC 46 ms
19,888 KB
testcase_25 AC 39 ms
17,664 KB
testcase_26 AC 22 ms
10,680 KB
testcase_27 AC 384 ms
79,472 KB
testcase_28 AC 119 ms
32,876 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=100000
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