結果

問題 No.1449 新プロランド
ユーザー nasubi24nasubi24
提出日時 2021-03-31 19:44:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 664 ms / 2,000 ms
コード長 784 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 87,384 KB
実行使用メモリ 134,604 KB
最終ジャッジ日時 2023-10-08 05:47:19
合計ジャッジ時間 10,644 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
81,976 KB
testcase_01 AC 179 ms
86,788 KB
testcase_02 AC 263 ms
88,756 KB
testcase_03 AC 134 ms
83,496 KB
testcase_04 AC 148 ms
84,996 KB
testcase_05 AC 664 ms
134,604 KB
testcase_06 AC 425 ms
111,620 KB
testcase_07 AC 430 ms
117,804 KB
testcase_08 AC 349 ms
110,900 KB
testcase_09 AC 389 ms
92,600 KB
testcase_10 AC 509 ms
128,448 KB
testcase_11 AC 201 ms
100,404 KB
testcase_12 AC 362 ms
110,244 KB
testcase_13 AC 497 ms
104,532 KB
testcase_14 AC 205 ms
100,736 KB
testcase_15 AC 388 ms
109,100 KB
testcase_16 AC 323 ms
99,464 KB
testcase_17 AC 322 ms
101,476 KB
testcase_18 AC 112 ms
82,192 KB
testcase_19 AC 107 ms
91,116 KB
testcase_20 AC 109 ms
81,888 KB
testcase_21 AC 182 ms
95,840 KB
testcase_22 AC 192 ms
87,120 KB
testcase_23 AC 244 ms
103,020 KB
testcase_24 AC 472 ms
99,220 KB
testcase_25 AC 208 ms
89,916 KB
testcase_26 AC 158 ms
84,372 KB
testcase_27 AC 457 ms
118,996 KB
testcase_28 AC 356 ms
98,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n,m=map(int,input().split())
ans=[[10**10]*(12**4+500000//n) 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 or min(ans[-1])==10**10:
    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]<12**4+500000//n:
       	    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