結果

問題 No.1 道のショートカット
ユーザー Mao-betaMao-beta
提出日時 2024-02-27 22:28:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 77 ms / 5,000 ms
コード長 1,162 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 70,696 KB
最終ジャッジ日時 2024-02-27 22:28:21
合計ジャッジ時間 4,997 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,752 KB
testcase_01 AC 47 ms
55,752 KB
testcase_02 AC 50 ms
55,752 KB
testcase_03 AC 46 ms
55,752 KB
testcase_04 AC 54 ms
55,752 KB
testcase_05 AC 47 ms
55,752 KB
testcase_06 AC 46 ms
55,752 KB
testcase_07 AC 47 ms
57,828 KB
testcase_08 AC 63 ms
68,604 KB
testcase_09 AC 58 ms
66,512 KB
testcase_10 AC 62 ms
68,592 KB
testcase_11 AC 63 ms
68,604 KB
testcase_12 AC 66 ms
68,592 KB
testcase_13 AC 66 ms
68,576 KB
testcase_14 AC 52 ms
63,540 KB
testcase_15 AC 46 ms
55,752 KB
testcase_16 AC 55 ms
66,528 KB
testcase_17 AC 48 ms
61,420 KB
testcase_18 AC 51 ms
63,796 KB
testcase_19 AC 50 ms
63,540 KB
testcase_20 AC 59 ms
66,516 KB
testcase_21 AC 56 ms
63,924 KB
testcase_22 AC 60 ms
63,796 KB
testcase_23 AC 70 ms
70,684 KB
testcase_24 AC 69 ms
70,696 KB
testcase_25 AC 60 ms
66,528 KB
testcase_26 AC 55 ms
63,924 KB
testcase_27 AC 65 ms
68,596 KB
testcase_28 AC 50 ms
61,420 KB
testcase_29 AC 65 ms
70,680 KB
testcase_30 AC 59 ms
66,512 KB
testcase_31 AC 63 ms
68,588 KB
testcase_32 AC 62 ms
66,516 KB
testcase_33 AC 61 ms
66,520 KB
testcase_34 AC 68 ms
68,592 KB
testcase_35 AC 61 ms
66,360 KB
testcase_36 AC 63 ms
68,472 KB
testcase_37 AC 77 ms
68,600 KB
testcase_38 AC 50 ms
61,412 KB
testcase_39 AC 53 ms
63,540 KB
testcase_40 AC 59 ms
66,400 KB
testcase_41 AC 52 ms
61,412 KB
testcase_42 AC 49 ms
55,752 KB
testcase_43 AC 48 ms
57,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import bisect
from heapq import heapify, heappop, heappush
from collections import deque, defaultdict, Counter
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD99 = 998244353

input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
SMI = lambda: input().split()
SLI = lambda: list(SMI())
EI = lambda m: [NLI() for _ in range(m)]


def main():
    N = NI()
    C = NI()
    V = NI()
    S = NLI()
    T = NLI()
    Y = NLI()
    M = NLI()
    INF = 10**18
    dp = [[INF]*(C+1) for _ in range(N)]
    dp[0][C] = 0
    E = [[s-1, t-1, y, m] for s, t, y, m in zip(S, T, Y, M)]
    E.sort()
    for s, t, y, m in E:
        for c in range(C+1):
            if dp[s][c] >= INF:
                continue
            if c - y < 0:
                continue
            dp[t][c-y] = min(dp[t][c-y], dp[s][c] + m)
    ans = min(dp[-1])
    if ans < INF:
        print(ans)
    else:
        print(-1)


if __name__ == "__main__":
    main()
0