結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,428 KB
testcase_01 AC 18 ms
8,556 KB
testcase_02 AC 19 ms
8,868 KB
testcase_03 AC 18 ms
8,704 KB
testcase_04 AC 18 ms
8,676 KB
testcase_05 AC 63 ms
15,564 KB
testcase_06 AC 29 ms
12,772 KB
testcase_07 AC 30 ms
12,976 KB
testcase_08 AC 44 ms
15,584 KB
testcase_09 AC 21 ms
9,848 KB
testcase_10 AC 33 ms
14,248 KB
testcase_11 AC 35 ms
15,108 KB
testcase_12 AC 64 ms
14,696 KB
testcase_13 AC 23 ms
10,660 KB
testcase_14 AC 36 ms
15,328 KB
testcase_15 AC 31 ms
13,452 KB
testcase_16 AC 25 ms
11,260 KB
testcase_17 AC 35 ms
12,560 KB
testcase_18 AC 17 ms
8,624 KB
testcase_19 AC 31 ms
13,524 KB
testcase_20 AC 17 ms
8,412 KB
testcase_21 AC 29 ms
13,064 KB
testcase_22 AC 19 ms
9,032 KB
testcase_23 AC 34 ms
14,840 KB
testcase_24 AC 20 ms
9,476 KB
testcase_25 AC 19 ms
9,240 KB
testcase_26 AC 18 ms
8,664 KB
testcase_27 AC 140 ms
16,488 KB
testcase_28 AC 35 ms
11,028 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