結果

問題 No.90 品物の並び替え
ユーザー shinjiwebshinjiweb
提出日時 2016-08-28 01:40:40
言語 Ruby
(3.2.2)
結果
AC  
実行時間 1,729 ms / 5,000 ms
コード長 382 bytes
コンパイル時間 412 ms
コンパイル使用メモリ 11,572 KB
実行使用メモリ 76,228 KB
最終ジャッジ日時 2023-08-08 14:32:28
合計ジャッジ時間 4,019 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,144 KB
testcase_01 AC 233 ms
18,716 KB
testcase_02 AC 81 ms
15,092 KB
testcase_03 AC 95 ms
15,612 KB
testcase_04 AC 95 ms
15,800 KB
testcase_05 AC 231 ms
18,928 KB
testcase_06 AC 232 ms
18,708 KB
testcase_07 AC 84 ms
15,476 KB
testcase_08 AC 83 ms
15,216 KB
testcase_09 AC 1,729 ms
76,228 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