結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,172 KB
testcase_01 AC 82 ms
15,308 KB
testcase_02 AC 79 ms
15,156 KB
testcase_03 AC 80 ms
15,340 KB
testcase_04 WA -
testcase_05 AC 80 ms
15,020 KB
testcase_06 AC 82 ms
15,080 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 78 ms
15,324 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 79 ms
15,132 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
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 79 ms
15,140 KB
testcase_43 AC 80 ms
15,176 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - v
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..n).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)
	puts '-1'
else
	puts sum_m[n][1]
end
0