結果

問題 No.90 品物の並び替え
ユーザー shinjiwebshinjiweb
提出日時 2016-08-28 01:40:40
言語 Ruby
(3.3.0)
結果
AC  
実行時間 2,035 ms / 5,000 ms
コード長 382 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 74,496 KB
最終ジャッジ日時 2024-04-26 07:14:27
合計ジャッジ時間 4,381 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
12,160 KB
testcase_01 AC 260 ms
15,232 KB
testcase_02 AC 84 ms
12,160 KB
testcase_03 AC 104 ms
12,416 KB
testcase_04 AC 99 ms
12,288 KB
testcase_05 AC 257 ms
15,616 KB
testcase_06 AC 260 ms
15,744 KB
testcase_07 AC 88 ms
12,032 KB
testcase_08 AC 86 ms
12,416 KB
testcase_09 AC 2,035 ms
74,496 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, m = gets.split.map(&:to_i)
score_table = Array.new(n){ Array.new(n, 0) }
m.times do
  i, j, s = gets.split.map(&:to_i)
  score_table[i][j] = s
end
max_score = 0
perm = (0..(n - 1)).to_a.permutation(n).to_a
perm.each do |a|
  score = 0
  n.times do |j|
    j.times do |i|
      score += score_table[a[i]][a[j]]
    end
  end
  max_score = [max_score, score].max
end
puts max_score
0