結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
convexineq
|
| 提出日時 | 2020-12-04 21:45:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 60 ms / 5,000 ms |
| コード長 | 587 bytes |
| コンパイル時間 | 482 ms |
| コンパイル使用メモリ | 82,280 KB |
| 実行使用メモリ | 66,432 KB |
| 最終ジャッジ日時 | 2024-09-15 08:27:43 |
| 合計ジャッジ時間 | 3,953 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
ソースコード
n = int(input())
c = int(input())
v = int(input())
*s, = map(int,input().split())
*t, = map(int,input().split())
*y, = map(int,input().split())
*m, = map(int,input().split())
g = [[] for _ in range(n)]
for ss,tt,yy,mm in zip(s,t,y,m):
g[ss-1].append((tt-1,yy,mm))
INF = 10**9
res = [[INF]*(c+1) for _ in range(n)]
res[0][0] = 0
for i in range(n):
for j in range(c+1):
if res[i][j] == INF: continue
for tt,yy,mm in g[i]:
if j+yy <= c:
res[tt][j+yy] = min(res[tt][j+yy], res[i][j]+mm)
ans = min(res[-1])
print(ans if ans!=INF else -1)
convexineq