結果

問題 No.90 品物の並び替え
ユーザー akko_yukkyakko_yukky
提出日時 2018-04-29 23:20:24
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 473 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 11,444 KB
実行使用メモリ 21,128 KB
最終ジャッジ日時 2023-09-10 08:14:02
合計ジャッジ時間 8,970 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
19,656 KB
testcase_01 AC 504 ms
15,904 KB
testcase_02 AC 79 ms
15,088 KB
testcase_03 AC 102 ms
15,732 KB
testcase_04 AC 121 ms
15,740 KB
testcase_05 AC 568 ms
15,896 KB
testcase_06 AC 405 ms
15,784 KB
testcase_07 AC 82 ms
15,216 KB
testcase_08 AC 79 ms
15,152 KB
testcase_09 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - m
Syntax OK

ソースコード

diff #

first_row = gets.split.map(&:to_i)
n = first_row[0]
m = first_row[1]

input = STDIN.read.split("\n")

Criteria = Struct.new(:item1, :item2, :score)

crt = []

input.each do |item|
  tmp = item.split.map!(&:to_i)
  str = Criteria.new(tmp[0], tmp[1], tmp[2])
  crt << str
end

ans = 0
(0..(n - 1)).to_a.permutation do |i|
  tmp = 0
  crt.each do |crt|
    if i.index(crt.item1) < i.index(crt.item2)
      tmp += crt.score
    end
    ans = [ans, tmp].max
  end
end

puts ans
0