結果

問題 No.1 道のショートカット
コンテスト
ユーザー netyo715
提出日時 2021-07-09 11:06:29
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 625 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 508 ms
コンパイル使用メモリ 20,700 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2026-03-22 15:50:59
合計ジャッジ時間 6,951 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other WA * 40
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
C = int(input())
V = int(input())
S = list(map(lambda x: int(x)-1, input().split()))
T = list(map(lambda x: int(x)-1, input().split()))
Y = list(map(int, input().split()))
M = list(map(int, input().split()))
INF = 10**10
edge = [[] for _ in range(N)]
for s, t, y, m in zip(S, T, Y, M):
    edge[s].append([t, y, m])
dp = [[INF]*(C+10) for _ in range(N+10)]
dp[0][0] = 0

for i in range(N-1):
    for t, y, m in edge[i]:
        for j in range(C+1):
            if j+y > C:
                break
            dp[t][j+y] = min(dp[t][j+y], dp[i][j]+m)

if min(dp[N-1])==INF:
    print(-1)
    print(min(dp[N-1]))
0