結果
| 問題 | No.1 道のショートカット |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-10 18:04:07 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 97 ms / 5,000 ms |
| コード長 | 545 bytes |
| 記録 | |
| コンパイル時間 | 171 ms |
| コンパイル使用メモリ | 77,460 KB |
| 最終ジャッジ日時 | 2025-12-03 22:37:09 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
ソースコード
N=int(raw_input())
C=int(raw_input())
V=int(raw_input())
S=map(int,raw_input().split())
T=map(int,raw_input().split())
Y=map(int,raw_input().split())
M=map(int,raw_input().split())
edge=[]
for i in xrange(V):
edge.append((S[i]-1,T[i]-1,Y[i], M[i]))
edge=sorted(edge)
dp=[[10**9]*(C+1) for _ in xrange(N)]
dp[0][C]=0
for e in edge:
for j in xrange(C+1):
if j+e[2]>C: continue
dp[e[1]][j] = min(dp[e[1]][j], dp[e[0]][j+e[2]]+e[3])
ans = 10**9
for i in xrange(C+1):
ans = min(ans, dp[N-1][i])
if ans==10**9: print -1
else: print ans