結果
| 問題 | No.90 品物の並び替え |
| コンテスト | |
| ユーザー |
akko_yukky
|
| 提出日時 | 2018-04-29 23:20:24 |
| 言語 | Ruby (4.0.1) |
| 結果 |
AC
|
| 実行時間 | 4,119 ms / 5,000 ms |
| コード長 | 473 bytes |
| 記録 | |
| コンパイル時間 | 306 ms |
| コンパイル使用メモリ | 9,088 KB |
| 実行使用メモリ | 15,872 KB |
| 最終ジャッジ日時 | 2026-03-16 05:45:03 |
| 合計ジャッジ時間 | 6,510 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - m Syntax OK
ソースコード
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
akko_yukky