結果

問題 No.1 道のショートカット
ユーザー warashiwarashi
提出日時 2016-01-13 17:25:38
言語 Go
(1.22.1)
結果
MLE  
実行時間 -
コード長 997 bytes
コンパイル時間 10,233 ms
コンパイル使用メモリ 210,864 KB
実行使用メモリ 810,880 KB
最終ジャッジ日時 2023-09-22 12:37:00
合計ジャッジ時間 13,502 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 19 ms
4,380 KB
testcase_09 AC 14 ms
4,380 KB
testcase_10 AC 19 ms
4,376 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 #

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)
}
0