結果

問題 No.134 走れ!サブロー君
ユーザー gigurururugigurururu
提出日時 2015-01-25 17:57:21
言語 Ruby
(3.2.2)
結果
AC  
実行時間 1,098 ms / 5,000 ms
コード長 340 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 11,468 KB
実行使用メモリ 29,004 KB
最終ジャッジ日時 2023-08-26 23:10:57
合計ジャッジ時間 5,350 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,316 KB
testcase_01 AC 81 ms
15,020 KB
testcase_02 AC 80 ms
15,080 KB
testcase_03 AC 91 ms
15,404 KB
testcase_04 AC 106 ms
15,412 KB
testcase_05 AC 141 ms
16,136 KB
testcase_06 AC 236 ms
17,556 KB
testcase_07 AC 473 ms
20,920 KB
testcase_08 AC 1,098 ms
29,004 KB
testcase_09 AC 1,089 ms
28,756 KB
testcase_10 AC 80 ms
15,356 KB
testcase_11 AC 81 ms
15,116 KB
testcase_12 AC 82 ms
15,320 KB
testcase_13 AC 81 ms
15,044 KB
testcase_14 AC 81 ms
15,152 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def g;gets.split.map(&:to_f)end
X,Y=g
n,=g
L=(1..n).map{g}+[[X,Y,0]]
Memo=L.map{{}}
def dfs(a,left)
  x,y,=L[a]
  Memo[a][left]||=left[0]?(left.map{|i|
    t,u,=L[i]
    dfs(i,left-[i])+((x-t).abs+(y-u).abs)*(left.inject(0){|s,r|s+L[r][2]}+100.0)/120
  }.min):((X-x).abs+(Y-y).abs)*(100.0)/120
end
p dfs(n,[*0...n])+L.inject(0){|s,r|s+r[2]}
0