結果

問題 No.1449 新プロランド
ユーザー nasubi24nasubi24
提出日時 2021-03-31 15:51:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 660 ms / 2,000 ms
コード長 760 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 134,628 KB
最終ジャッジ日時 2023-08-25 16:49:40
合計ジャッジ時間 10,100 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
81,932 KB
testcase_01 AC 180 ms
86,640 KB
testcase_02 AC 264 ms
88,644 KB
testcase_03 AC 134 ms
83,492 KB
testcase_04 AC 146 ms
84,932 KB
testcase_05 AC 660 ms
134,628 KB
testcase_06 AC 422 ms
111,868 KB
testcase_07 AC 438 ms
117,576 KB
testcase_08 AC 348 ms
110,956 KB
testcase_09 AC 389 ms
92,504 KB
testcase_10 AC 507 ms
128,500 KB
testcase_11 AC 199 ms
99,772 KB
testcase_12 AC 366 ms
109,880 KB
testcase_13 AC 495 ms
104,712 KB
testcase_14 AC 206 ms
100,156 KB
testcase_15 AC 383 ms
108,544 KB
testcase_16 AC 324 ms
99,100 KB
testcase_17 AC 323 ms
101,696 KB
testcase_18 AC 113 ms
82,244 KB
testcase_19 AC 109 ms
90,788 KB
testcase_20 AC 108 ms
81,848 KB
testcase_21 AC 184 ms
95,620 KB
testcase_22 AC 193 ms
87,344 KB
testcase_23 AC 245 ms
103,248 KB
testcase_24 AC 475 ms
99,480 KB
testcase_25 AC 208 ms
89,780 KB
testcase_26 AC 157 ms
84,236 KB
testcase_27 AC 457 ms
118,808 KB
testcase_28 AC 356 ms
98,304 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:
    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