結果

問題 No.472 平均順位
ユーザー cielciel
提出日時 2020-08-14 11:14:06
言語 Crystal
(1.11.2)
結果
TLE  
実行時間 -
コード長 412 bytes
コンパイル時間 20,003 ms
コンパイル使用メモリ 260,592 KB
実行使用メモリ 227,200 KB
最終ジャッジ日時 2023-09-13 11:52:27
合計ジャッジ時間 25,009 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,484 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,500 KB
testcase_04 AC 6 ms
5,056 KB
testcase_05 AC 3 ms
4,476 KB
testcase_06 AC 3 ms
5,036 KB
testcase_07 AC 11 ms
5,864 KB
testcase_08 AC 119 ms
19,860 KB
testcase_09 AC 780 ms
79,404 KB
testcase_10 AC 616 ms
70,604 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(Tuple(Int32,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(Tuple(Int32,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