AtCoder-Library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub ryusuke920/AtCoder-Library

:heavy_check_mark: Test/yukicoder/0001.test.py

Code

# verification-helper: PROBLEM https://yukicoder.me/problems/no/1

from collections import defaultdict

def main() -> None:

    n = int(input())
    c = int(input())
    v = int(input())
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))
    y = list(map(int, input().split()))
    m = list(map(int, input().split()))

    INF = 10 ** 18
    d_time = defaultdict(list) # d_time[i_j] := iからjへかかる時間
    d_cost = defaultdict(list) # d_cost[i_j] := iからjへかかるコスト

    for i in range(v):
        d_time[f'{s[i]}_{t[i]}'].append(m[i])
        d_cost[f'{s[i]}_{t[i]}'].append(y[i])

    # dp[i][j] := i番目の町にいて、かかったコストがjである時のかかった時間の最小値
    # dp[i][j] = min(dp[i][j], dp[k][j - y[j]] + c[j]) (1 <= k < i)

    dp = [[INF] * (c + 1) for _ in range(n + 1)]
    for j in range(c + 1):
        dp[1][j] = 0

    for i in range(1, n + 1):
        for k in range(1, i):
            for j in range(c + 1):
                for p, q in zip(d_cost[f'{k}_{i}'], d_time[f'{k}_{i}']):
                    if j - p >= 0:
                        # k -> iに行く場合の更新路があるか考える。 (k < i)
                        dp[i][j] = min(dp[i][j], dp[k][j - p] + q)

    ans = INF
    for j in range(c + 1):
        ans = min(ans, dp[-1][j])

    print(ans) if ans != INF else print(-1)


if __name__ == "__main__":
    main()
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/python.py", line 96, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page