結果

問題 No.519 アイドルユニット
ユーザー letrangerjpletrangerjp
提出日時 2017-06-01 19:30:42
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 372 bytes
コンパイル時間 43 ms
コンパイル使用メモリ 11,932 KB
実行使用メモリ 39,520 KB
最終ジャッジ日時 2023-10-21 20:16:21
合計ジャッジ時間 17,388 ms
ジャッジサーバーID
(参考情報)
judge9 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 588 ms
25,528 KB
testcase_03 AC 140 ms
17,624 KB
testcase_04 AC 83 ms
16,040 KB
testcase_05 AC 84 ms
16,040 KB
testcase_06 AC 83 ms
16,036 KB
testcase_07 AC 85 ms
16,040 KB
testcase_08 AC 86 ms
16,040 KB
testcase_09 AC 92 ms
16,560 KB
testcase_10 AC 105 ms
16,928 KB
testcase_11 AC 138 ms
17,624 KB
testcase_12 AC 82 ms
16,040 KB
testcase_13 AC 139 ms
17,624 KB
testcase_14 AC 135 ms
17,624 KB
testcase_15 AC 136 ms
17,624 KB
testcase_16 AC 137 ms
17,624 KB
testcase_17 AC 136 ms
17,624 KB
testcase_18 AC 138 ms
17,624 KB
testcase_19 AC 138 ms
17,624 KB
testcase_20 AC 140 ms
17,624 KB
testcase_21 AC 137 ms
17,624 KB
testcase_22 AC 138 ms
17,624 KB
testcase_23 AC 139 ms
17,624 KB
testcase_24 AC 250 ms
19,232 KB
testcase_25 AC 254 ms
19,232 KB
testcase_26 AC 250 ms
19,232 KB
testcase_27 AC 249 ms
19,232 KB
testcase_28 AC 248 ms
19,232 KB
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 85 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] ||= []
    $chemistory[x][y]= v
  }
}

$dp={}
def g(unused)
  $dp[unused] ||= if unused.empty?
    0
  else
    a = unused.first
    (unused - [a]).inject(0){|r,b|
      [r, $chemistory[a][b] + g(unused - [a, b])].max
    }
  end
end

p g([*0...N])
0