結果
問題 | No.1 道のショートカット |
ユーザー |
|
提出日時 | 2022-09-05 16:14:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 104 ms / 5,000 ms |
コード長 | 898 bytes |
コンパイル時間 | 193 ms |
コンパイル使用メモリ | 82,348 KB |
実行使用メモリ | 71,712 KB |
最終ジャッジ日時 | 2024-11-20 16:55:27 |
合計ジャッジ時間 | 4,219 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 40 |
ソースコード
def I():return int(input()) def MAP():return map(int,input().split()) def MAPs():return map(str,input().split()) def LI(): return list(map(int,input().split())) def TPL(): return tuple(map(int,input().split())) def S():return input() from collections import defaultdict,Counter,deque from copy import deepcopy from heapq import heapify,heappop,heappush from bisect import bisect_left,bisect_right from itertools import accumulate,product,permutations,combinations from math import gcd,ceil,floor,sqrt inf=float('inf') n=I() c=I() v=I() s=LI() t=LI() y=LI() m=LI() dp=[[inf]*(c+1) for _ in range(n+1)] dp[1][c]=0 for i in range(1,n+1): for j in range(c,-1,-1): if dp[i][j]!=inf: for k in range(v): if i==s[k] and j-y[k]>=0: dp[t[k]][j-y[k]]=min(dp[i][j]+m[k],dp[t[k]][j-y[k]]) if min(dp[n])==inf: print(-1) else: print(min(dp[n]))