結果

問題 No.472 平均順位
ユーザー cielciel
提出日時 2016-12-22 01:14:54
言語 Crystal
(1.14.0)
結果
TLE  
実行時間 -
コード長 401 bytes
コンパイル時間 12,456 ms
コンパイル使用メモリ 302,852 KB
実行使用メモリ 240,684 KB
最終ジャッジ日時 2024-06-30 19:10:51
合計ジャッジ時間 20,430 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 6 TLE * 2 -- * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

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