結果

問題 No.519 アイドルユニット
ユーザー letrangerjpletrangerjp
提出日時 2017-06-01 19:25:33
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 341 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 21,116 KB
最終ジャッジ日時 2023-10-21 20:16:37
合計ジャッジ時間 12,450 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 422 ms
17,268 KB
testcase_03 AC 127 ms
16,492 KB
testcase_04 AC 87 ms
16,040 KB
testcase_05 AC 87 ms
16,040 KB
testcase_06 AC 87 ms
16,040 KB
testcase_07 AC 88 ms
16,040 KB
testcase_08 AC 87 ms
16,040 KB
testcase_09 AC 91 ms
16,040 KB
testcase_10 AC 101 ms
16,224 KB
testcase_11 AC 126 ms
16,492 KB
testcase_12 AC 84 ms
16,040 KB
testcase_13 AC 127 ms
16,492 KB
testcase_14 AC 132 ms
16,492 KB
testcase_15 AC 125 ms
16,492 KB
testcase_16 AC 125 ms
16,492 KB
testcase_17 AC 124 ms
16,492 KB
testcase_18 AC 125 ms
16,492 KB
testcase_19 AC 126 ms
16,492 KB
testcase_20 AC 125 ms
16,492 KB
testcase_21 AC 124 ms
16,492 KB
testcase_22 AC 127 ms
16,492 KB
testcase_23 AC 124 ms
16,492 KB
testcase_24 AC 202 ms
16,756 KB
testcase_25 AC 201 ms
16,756 KB
testcase_26 AC 203 ms
16,756 KB
testcase_27 AC 201 ms
16,756 KB
testcase_28 AC 200 ms
16,756 KB
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 86 ms
16,040 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
$chemistory = {}
N.times.each{|y|
  gets.split.take(N).map(&:to_i).each_with_index{|v, x|
    $chemistory[[x,y]] = v
  }
}

$dp={}
def g(u)
  $dp[u] ||= if u == 0
    0
  else
    (a=u.bit_length-1).times.inject(0){|r, b|
      [r, u[b] > 0 ? $chemistory[[a,b]] + g(u ^ (1<<b) ^ (1<<a)) : r].max
    }
  end
end

p g((1<<N)-1)
0