結果
問題 |
No.1 道のショートカット
|
ユーザー |
|
提出日時 | 2022-09-05 16:14:30 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,503 ms / 5,000 ms |
コード長 | 898 bytes |
コンパイル時間 | 264 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-11-20 16:56:00 |
合計ジャッジ時間 | 10,110 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]))