結果

問題 No.1449 新プロランド
ユーザー mkawa2mkawa2
提出日時 2021-03-31 15:32:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 1,212 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 149,488 KB
最終ジャッジ日時 2023-08-25 16:48:52
合計ジャッジ時間 4,992 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
72,932 KB
testcase_01 AC 81 ms
74,412 KB
testcase_02 AC 79 ms
75,736 KB
testcase_03 AC 78 ms
74,488 KB
testcase_04 AC 78 ms
74,740 KB
testcase_05 AC 194 ms
144,540 KB
testcase_06 AC 109 ms
114,960 KB
testcase_07 AC 108 ms
117,644 KB
testcase_08 AC 166 ms
148,560 KB
testcase_09 AC 85 ms
85,424 KB
testcase_10 AC 118 ms
130,872 KB
testcase_11 AC 121 ms
137,760 KB
testcase_12 AC 198 ms
137,172 KB
testcase_13 AC 95 ms
94,040 KB
testcase_14 AC 127 ms
140,728 KB
testcase_15 AC 113 ms
121,360 KB
testcase_16 AC 99 ms
99,528 KB
testcase_17 AC 148 ms
120,068 KB
testcase_18 AC 79 ms
73,896 KB
testcase_19 AC 114 ms
122,832 KB
testcase_20 AC 78 ms
73,112 KB
testcase_21 AC 110 ms
117,624 KB
testcase_22 AC 80 ms
76,808 KB
testcase_23 AC 123 ms
135,296 KB
testcase_24 AC 85 ms
82,768 KB
testcase_25 AC 82 ms
80,536 KB
testcase_26 AC 77 ms
73,632 KB
testcase_27 AC 266 ms
149,488 KB
testcase_28 AC 140 ms
102,604 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