結果

問題 No.90 品物の並び替え
ユーザー gemmarogemmaro
提出日時 2020-07-23 08:13:09
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 360 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 11,484 KB
実行使用メモリ 24,040 KB
最終ジャッジ日時 2023-09-05 20:37:42
合計ジャッジ時間 9,133 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,124 KB
testcase_01 AC 563 ms
16,720 KB
testcase_02 AC 78 ms
15,216 KB
testcase_03 AC 122 ms
16,440 KB
testcase_04 AC 135 ms
16,328 KB
testcase_05 AC 611 ms
16,760 KB
testcase_06 AC 504 ms
16,716 KB
testcase_07 AC 88 ms
16,108 KB
testcase_08 AC 78 ms
15,276 KB
testcase_09 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

class Hash
  def score
    I.map do |l, r, s|
      self[l] < self[r] ? s : 0
    end.sum
  end
end

def solve
  (0..(N - 1))
    .to_a
    .permutation
    .map { |p| p.map.with_index { |q, i| { q => i } }.reduce(&:merge).score }
    .max
end

N, M = gets.split.map(&:to_i)
I = M.times.map { gets.split.map(&:to_i) }

puts solve
0