結果

問題 No.1 道のショートカット
ユーザー sue_charosue_charo
提出日時 2017-06-01 19:09:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 1,413 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 11,032 KB
実行使用メモリ 796,408 KB
最終ジャッジ日時 2023-09-22 13:08:38
合計ジャッジ時間 8,480 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,148 KB
testcase_01 AC 32 ms
10,140 KB
testcase_02 AC 31 ms
10,092 KB
testcase_03 AC 31 ms
10,084 KB
testcase_04 AC 32 ms
10,088 KB
testcase_05 AC 32 ms
10,260 KB
testcase_06 AC 32 ms
10,028 KB
testcase_07 AC 31 ms
10,124 KB
testcase_08 AC 42 ms
11,136 KB
testcase_09 AC 33 ms
10,268 KB
testcase_10 AC 56 ms
12,496 KB
testcase_11 MLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N = II()
    C = II()
    V = II()
    S = ILI()
    T = ILI()
    Y = ILI()
    M = ILI()
    return (N, C, V, S, T, Y, M)


def solve(N, C, V, S, T, Y, M):
    edge = collections.defaultdict(list)
    for i in range(V):
        edge[S[i]].append((T[i], Y[i], M[i]))
    # vertex list. 0-indexed. has all (time, cost).
    l_vertex = [[] for __ in range(N)]
    l_vertex[0].append((0, 0))
    for i in range(N):
        now_ver = l_vertex[i]
        for v in now_ver:
            for e in edge[i + 1]:
                next_ver = e[0] - 1
                next_cost = v[1] + e[1]
                next_time = v[0] + e[2]
                if next_cost > C:
                    continue
                else:
                    l_vertex[next_ver].append((next_time, next_cost))

    ans = 0
    if len(l_vertex[N - 1]) == 0:
        ans = -1
    else:
        l_ans = sorted(l_vertex[N - 1])
        ans = l_ans[0][0]

    return ans


def main():
    params = read()
    print(solve(*params))


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