結果

問題 No.1 道のショートカット
コンテスト
ユーザー drymouse
提出日時 2024-02-12 14:53:37
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 811 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 409 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 23,460 KB
最終ジャッジ日時 2026-04-15 07:07:13
合計ジャッジ時間 9,576 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 TLE * 1 -- * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def intm(string):
    return int(string) - 1

# return minimum time to N
def goforward(start, curcost, curtime):
    if start == N - 1:
        return curtime
    smallest = 1e+10
    for i in range(V):
        if S[i] == start:
            nexcost = curcost + Y[i]
            nextime = curtime + M[i]
            if nexcost > C:continue
            result = goforward(T[i], nexcost, nextime)
            #print("{} -> {} :{}".format(start, T[i], result))
            smallest = min(smallest, result)

    return smallest


N = int(input())
C = int(input())
V = int(input())
S = list(map(intm, input().split(" ")))
T = list(map(intm, input().split(" ")))
Y = list(map(int, input().split(" ")))
M = list(map(int, input().split(" ")))

result = goforward(0, 0, 0)
if result >= 1e+9:
    result = -1
print(result)
0