結果

問題 No.90 品物の並び替え
ユーザー akko_yukkyakko_yukky
提出日時 2018-04-29 23:31:01
言語 Ruby
(3.4.1)
結果
TLE  
実行時間 -
コード長 409 bytes
コンパイル時間 35 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 20,252 KB
最終ジャッジ日時 2024-06-27 23:43:54
合計ジャッジ時間 8,867 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8 TLE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets[0].to_i

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

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

crt = []

input.each do |item|
  tmp = item.split.map!(&:to_i)
  crt << Criteria.new(tmp[0], tmp[1], tmp[2])
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