結果
問題 | No.1 道のショートカット |
ユーザー |
|
提出日時 | 2024-02-27 22:28:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 64 ms / 5,000 ms |
コード長 | 1,162 bytes |
コンパイル時間 | 185 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 69,504 KB |
最終ジャッジ日時 | 2024-09-29 12:10:35 |
合計ジャッジ時間 | 3,767 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 40 |
ソースコード
import sysimport mathimport bisectfrom heapq import heapify, heappop, heappushfrom collections import deque, defaultdict, Counterfrom functools import lru_cachefrom itertools import accumulate, combinations, permutations, productsys.setrecursionlimit(1000000)MOD = 10 ** 9 + 7MOD99 = 998244353input = 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**18dp = [[INF]*(C+1) for _ in range(N)]dp[0][C] = 0E = [[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:continueif c - y < 0:continuedp[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()