結果

問題 No.472 平均順位
ユーザー ciel
提出日時 2020-08-14 11:10:38
言語 Crystal
(1.14.0)
結果
TLE  
実行時間 -
コード長 400 bytes
コンパイル時間 12,379 ms
コンパイル使用メモリ 299,408 KB
実行使用メモリ 234,704 KB
最終ジャッジ日時 2024-06-30 21:03:25
合計ジャッジ時間 19,813 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 6 TLE * 2 -- * 8
権限があれば一括ダウンロードができます

ソースコード

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=n.times.map{gets.not_nil!.split.map(&.to_i)+[1_i32]}.to_a
p dfs(memo,v,0,k) / n.to_f
0