結果
| 問題 | No.9 モンスターのレベル上げ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-01-26 02:23:00 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,209 bytes |
| コンパイル時間 | 34 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 13,880 KB |
| 最終ジャッジ日時 | 2024-06-23 03:09:29 |
| 合計ジャッジ時間 | 6,900 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 TLE * 1 -- * 17 |
コンパイルメッセージ
Syntax OK
ソースコード
class Party
attr_reader :size
def initialize(level_list)
@level_list = level_list.clone
@size = @level_list.size
end
def clone
return self.class.new(@level_list)
end
def level_each_with_start_pos(start_pos)
@size.times do |i|
pos = (start_pos + i) % @size
yield @level_list[pos]
end
end
end
class OwnParty < Party
def initialize(level_list)
super
@count_list = [0] * @level_list.size
end
def clone
clone_op = super
clone_op.set_count_list(@count_list)
return clone_op
end
def set_count_list(count_list)
@count_list = count_list.clone
end
def max_count
return @count_list.max
end
def next_index
count_max_over = max_count + 1
min = (0...@size).min_by do |i|
@level_list[i] * count_max_over - @count_list[i]
end
return min
end
def level_up(i, exp)
@count_list[i] += 1
@level_list[i] += exp
end
end
gets
own = OwnParty.new(gets.split.map(&:to_i))
mon = Party.new(gets.split.map(&:to_i))
list = (0..mon.size).map do |i|
own_c = own.clone
mon.level_each_with_start_pos(i) do |level|
own_c.level_up(own_c.next_index, level / 2)
end
own_c.max_count
end
puts list.min