結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-01-13 17:25:38 |
| 言語 | Go (1.23.4) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 997 bytes |
| コンパイル時間 | 15,260 ms |
| コンパイル使用メモリ | 227,008 KB |
| 実行使用メモリ | 810,612 KB |
| 最終ジャッジ日時 | 2024-07-08 04:21:45 |
| 合計ジャッジ時間 | 18,084 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 MLE * 1 -- * 32 |
ソースコード
package main
import (
"fmt"
)
type next struct {
town, cost, time int
}
type costTime struct {
cost, time int
}
func scanIntSet(N int) []int {
ret := make([]int, N)
for i := 0; i < N; i++ {
fmt.Scan(&ret[i])
}
return ret
}
func main() {
// init
var N, C, V int
fmt.Scan(&N, &C, &V)
S := scanIntSet(V)
T := scanIntSet(V)
Y := scanIntSet(V)
M := scanIntSet(V)
e := make(map[int][]next)
for i := 0; i < V; i++ {
e[S[i]] = append(e[S[i]], next{T[i], Y[i], M[i]})
}
path := make([][]costTime, N+1)
path[1] = append(path[1], costTime{0, 0})
for i := 1; i <= N; i++ {
for _, now := range path[i] {
nexts := e[i]
for _, next := range nexts {
if next.cost+now.cost > C {
continue
}
path[next.town] = append(path[next.town], costTime{next.cost + now.cost, next.time + now.time})
}
}
}
if path[N] == nil {
fmt.Println(-1)
return
}
min := 1000*V + 1
for _, p := range path[N] {
if min > p.time {
min = p.time
}
}
fmt.Println(min)
}