結果

問題 No.472 平均順位
ユーザー cielciel
提出日時 2016-12-22 01:13:57
言語 Crystal
(1.14.0)
結果
RE  
実行時間 -
コード長 402 bytes
コンパイル時間 12,276 ms
コンパイル使用メモリ 300,860 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-30 19:09:02
合計ジャッジ時間 13,491 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 RE * 1
other RE * 16
権限があれば一括ダウンロードができます

ソースコード

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]||1_i64)].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)}.to_a
p dfs(memo,v,0,k) / n.to_f
0