結果

問題 No.90 品物の並び替え
ユーザー gigurururugigurururu
提出日時 2014-12-09 16:41:40
言語 Ruby
(3.3.0)
結果
AC  
実行時間 97 ms / 5,000 ms
コード長 222 bytes
コンパイル時間 930 ms
コンパイル使用メモリ 11,240 KB
実行使用メモリ 15,260 KB
最終ジャッジ日時 2023-09-02 12:12:15
合計ジャッジ時間 2,183 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
15,096 KB
testcase_01 AC 92 ms
15,040 KB
testcase_02 AC 87 ms
15,220 KB
testcase_03 AC 91 ms
15,040 KB
testcase_04 AC 91 ms
15,252 KB
testcase_05 AC 93 ms
15,224 KB
testcase_06 AC 91 ms
15,140 KB
testcase_07 AC 87 ms
15,024 KB
testcase_08 AC 84 ms
15,204 KB
testcase_09 AC 97 ms
15,260 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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