結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-23 08:13:09 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 360 bytes |
| コンパイル時間 | 278 ms |
| コンパイル使用メモリ | 7,680 KB |
| 実行使用メモリ | 25,888 KB |
| 最終ジャッジ日時 | 2024-06-23 16:02:26 |
| 合計ジャッジ時間 | 9,329 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 TLE * 1 |
コンパイルメッセージ
Syntax OK
ソースコード
# 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