結果

問題 No.1 道のショートカット
ユーザー suppy193suppy193
提出日時 2015-06-17 14:57:13
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 764 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 11,452 KB
実行使用メモリ 15,652 KB
最終ジャッジ日時 2023-09-22 12:22:03
合計ジャッジ時間 5,497 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,236 KB
testcase_01 AC 82 ms
15,296 KB
testcase_02 AC 82 ms
15,084 KB
testcase_03 AC 82 ms
15,140 KB
testcase_04 WA -
testcase_05 AC 81 ms
15,336 KB
testcase_06 AC 82 ms
15,336 KB
testcase_07 AC 81 ms
15,036 KB
testcase_08 AC 87 ms
15,604 KB
testcase_09 AC 85 ms
15,288 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 82 ms
15,124 KB
testcase_16 WA -
testcase_17 AC 82 ms
15,292 KB
testcase_18 AC 83 ms
15,260 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 84 ms
15,036 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 84 ms
15,292 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 81 ms
15,144 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 85 ms
15,076 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 81 ms
15,280 KB
testcase_43 AC 81 ms
15,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.chomp.to_i
c = gets.chomp.to_i
v = gets.chomp.to_i
s = gets.chomp.split(' ')
t = gets.chomp.split(' ')
y = gets.chomp.split(' ')
m = gets.chomp.split(' ')
matrix = {}
sum_m = {}
sum_m[1] = [0, 0]
(1..v).each do |i|
	matrix[[s[i - 1].to_i, t[i - 1].to_i]] = [y[i - 1].to_i, m[i - 1].to_i]	
end
#p matrix.sort
(1...n).each do |i|
	next if !sum_m.key?(i)
	(i+1..n).each do |j|
		next if !matrix.key?([i, j])
		#print "#{i},#{j}\n"
		if !sum_m.key?(j)
			sum_m[j] = [c, 1000]	
		end
		if sum_m[j][1] > sum_m[i][1] + matrix[[i, j]][1] && sum_m[i][0] + matrix[[i, j]][0] <= c
			sum_m[j] = [sum_m[i][0] + matrix[[i, j]][0], sum_m[i][1] + matrix[[i, j]][1]]
		end
		#p sum_m
	end
end
if !sum_m.key?(n) || sum_m[n][1] == 1000
	puts '-1'
else
	puts sum_m[n][1]
end
0