結果

問題 No.472 平均順位
ユーザー cielciel
提出日時 2020-08-14 11:11:04
言語 Crystal
(1.11.2)
結果
TLE  
実行時間 -
コード長 400 bytes
コンパイル時間 18,384 ms
コンパイル使用メモリ 260,520 KB
実行使用メモリ 192,568 KB
最終ジャッジ日時 2023-09-13 11:50:34
合計ジャッジ時間 24,966 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,564 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,548 KB
testcase_03 AC 2 ms
4,436 KB
testcase_04 AC 6 ms
5,840 KB
testcase_05 AC 2 ms
4,464 KB
testcase_06 AC 4 ms
4,872 KB
testcase_07 AC 16 ms
7,844 KB
testcase_08 AC 240 ms
41,524 KB
testcase_09 AC 1,842 ms
192,568 KB
testcase_10 AC 1,303 ms
175,200 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env crystal
def dfs(
	memo : Hash(Array(Int32),Int32),
	v : Array(Array(Int32)),
	d : Int32,
	r : Int32
)
	return 0_i32 if d==v.size
	memo[[d,r]]||=(0..[r,3].min).reduce(1_i32<<30){|s,i|
		[s,dfs(memo,v,d+1,r-i)+v[d][i]].min
	}
end
memo=Hash(Array(Int32),Int32).new
n,k=gets.not_nil!.split.map(&.to_i)
v=(0...n).map{gets.not_nil!.split.map(&.to_i)+[1_i32]}.to_a
p dfs(memo,v,0,k) / n.to_f
0