結果

問題 No.1449 新プロランド
ユーザー nasubi24nasubi24
提出日時 2021-03-31 15:33:17
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 331 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 99,608 KB
最終ジャッジ日時 2023-08-25 16:48:58
合計ジャッジ時間 6,566 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
77,864 KB
testcase_01 AC 117 ms
77,872 KB
testcase_02 AC 130 ms
77,760 KB
testcase_03 AC 112 ms
77,800 KB
testcase_04 AC 114 ms
77,744 KB
testcase_05 AC 331 ms
99,608 KB
testcase_06 AC 239 ms
89,524 KB
testcase_07 AC 224 ms
88,844 KB
testcase_08 AC 210 ms
89,144 KB
testcase_09 AC 179 ms
79,024 KB
testcase_10 AC 262 ms
94,288 KB
testcase_11 AC 152 ms
86,032 KB
testcase_12 AC 208 ms
88,084 KB
testcase_13 AC 225 ms
83,648 KB
testcase_14 AC 147 ms
86,180 KB
testcase_15 AC 213 ms
87,312 KB
testcase_16 AC 177 ms
82,052 KB
testcase_17 AC 192 ms
84,280 KB
testcase_18 AC 97 ms
76,332 KB
testcase_19 AC 100 ms
76,916 KB
testcase_20 AC 97 ms
76,248 KB
testcase_21 AC 138 ms
82,116 KB
testcase_22 AC 125 ms
78,196 KB
testcase_23 AC 159 ms
85,940 KB
testcase_24 AC 182 ms
80,332 KB
testcase_25 AC 128 ms
79,352 KB
testcase_26 AC 116 ms
77,876 KB
testcase_27 AC 260 ms
94,508 KB
testcase_28 AC 188 ms
81,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n,m=map(int,input().split())
ans=[[10**10]*(10**4+10) for _ in range(n)]
num=[[] for _ in range(n)]
for i in range(m):
    a,b,c=map(int,input().split())
    num[a-1].append([b-1,c])
    num[b-1].append([a-1,c])
t=list(map(int,input().split()))
ans[0][t[0]]=t[0]
queue=deque()
queue.append([0,t[0]])
seen=[False]*n
seen[0]=True
while len(queue)!=0:
    num1=queue.popleft()
    h1=num1[0]
    h2=num1[1]
    num2=num[h1]
    seen[h1]=True
    num3=ans[h1][h2]
    for i in range(len(num2)):
        j=num2[i][0]
        if h2+t[j]<10**4+10:
       	    cnt=num3+num2[i][1]//h2+t[j]
            if ans[j][h2+t[j]]>cnt:
                ans[j][h2+t[j]]=cnt
                queue.append([j,h2+t[j]])
print(min(ans[-1]))
0