結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-03 23:08:10 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,272 bytes |
| コンパイル時間 | 93 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-07-08 03:55:49 |
| 合計ジャッジ時間 | 2,841 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 16 WA * 24 |
ソースコード
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))