結果

問題 No.1 道のショートカット
ユーザー rpy3cpprpy3cpp
提出日時 2015-08-06 21:42:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,272 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 10,960 KB
実行使用メモリ 8,808 KB
最終ジャッジ日時 2023-09-22 12:25:04
合計ジャッジ時間 2,963 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,352 KB
testcase_01 AC 16 ms
8,264 KB
testcase_02 AC 16 ms
8,340 KB
testcase_03 AC 16 ms
8,312 KB
testcase_04 WA -
testcase_05 AC 17 ms
8,384 KB
testcase_06 AC 16 ms
8,360 KB
testcase_07 AC 17 ms
8,292 KB
testcase_08 AC 32 ms
8,496 KB
testcase_09 AC 22 ms
8,116 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 17 ms
8,364 KB
testcase_16 WA -
testcase_17 AC 17 ms
8,408 KB
testcase_18 AC 17 ms
8,212 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 18 ms
8,420 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 19 ms
8,144 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 17 ms
8,304 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 21 ms
8,184 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 17 ms
8,428 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 17 ms
8,288 KB
testcase_43 AC 17 ms
8,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    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()))
    cost = [[float('inf')] * N for i in range(N)]
    time = [[float('inf')] * N for i in range(N)]
    for s, t, y, m in zip(S, T, Y, M):
        cost[s-1][t-1] = y
        time[s-1][t-1] = m
    return N, C, V, cost, time


def solve(N, C, V, cost, time):
    INF = float('inf')
    dp = [[INF] * (C + 1) for i in range(N)]
    dp[0][0] = 0
    for pos in range(N):
        cost_pos = cost[pos]
        time_pos = time[pos]
        for np in range(pos + 1, N):
            nc = cost_pos[np]
            if nc == INF:
                continue
            nt = time_pos[np]
            dp_np = dp[np]
            for c, m in enumerate(dp[pos]):
                if m == INF:
                    continue
                ncc = nc + c
                if ncc <= C and dp_np[ncc] > nt + m:
                    dp_np[ncc] = nt + m
    min_time = min(dp[N-1])
    if min_time == INF:
        return -1
    else:
        return min_time

if __name__ == '__main__':
    N, C, V, cost, time = read_data()
    print(solve(N, C, V, cost, time))
0