結果

問題 No.90 品物の並び替え
ユーザー gigurururugigurururu
提出日時 2014-12-07 20:56:38
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,599 ms / 5,000 ms
コード長 221 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 11,324 KB
実行使用メモリ 15,392 KB
最終ジャッジ日時 2023-09-02 10:26:06
合計ジャッジ時間 3,636 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,180 KB
testcase_01 AC 244 ms
15,392 KB
testcase_02 AC 80 ms
15,296 KB
testcase_03 AC 99 ms
15,272 KB
testcase_04 AC 105 ms
15,272 KB
testcase_05 AC 238 ms
15,204 KB
testcase_06 AC 239 ms
15,240 KB
testcase_07 AC 83 ms
15,284 KB
testcase_08 AC 78 ms
15,148 KB
testcase_09 AC 1,599 ms
15,156 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def g;gets.split.map(&:to_i)end
n,m=g
$s=(1..n).map{[0]*n}
m.times{
  a,b,c=g
  $s[a][b]=c
}
def dfs(done,left)
  left.map{|i|done.inject(0){|t,j|t+$s[j][i]}+dfs(done+[i],left-[i])}.max||0
end
p dfs([],[*0...n])
0