結果

問題 No.90 品物の並び替え
ユーザー shinjiweb
提出日時 2016-08-28 01:20:34
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 386 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 74,624 KB
最終ジャッジ日時 2024-11-08 20:13:08
合計ジャッジ時間 3,791 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, m = gets.split.map(&:to_i)
score_table = Array.new(n, Array.new(n, 0))
max_score = 0
m.times do
  i, j, s = gets.split.map(&:to_i)
  score_table[i][j] = s
end
perm = (0..(n - 1)).to_a.permutation(n).to_a
perm.each do |a|
  score = 0
  (n - 1).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