結果
問題 | No.1 道のショートカット |
ユーザー |
|
提出日時 | 2016-11-10 18:04:07 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 206 ms / 5,000 ms |
コード長 | 545 bytes |
コンパイル時間 | 47 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 6,912 KB |
最終ジャッジ日時 | 2024-07-20 16:27:19 |
合計ジャッジ時間 | 3,443 ms |
ジャッジサーバー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