結果
| 問題 |
No.9 モンスターのレベル上げ
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-09-05 09:20:11 |
| 言語 | Crystal (1.14.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 782 bytes |
| コンパイル時間 | 15,339 ms |
| コンパイル使用メモリ | 311,748 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-09-05 09:20:28 |
| 合計ジャッジ時間 | 13,191 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 20 |
ソースコード
n = gets.not_nil!.to_i
a = [] of {Int32, Int32}
n.times do
t = gets.not_nil!.to_i
a << {t, 0}
end
# Sort the initial array to act as a min-heap
a.sort_by! { |x| x[0] }
b = Array(Int32).new(n)
n.times do |i|
b[i] = gets.not_nil!.to_i
end
ans = 10**9
n.times do |i|
t = 0
# Create a deep copy of the array for simulation
ta = a.map { |x| {x[0], x[1]} }
n.times do |j|
# Get the smallest element (like popping from min-heap)
min_index = 0
ta.each_with_index do |element, idx|
if element[0] < ta[min_index][0]
min_index = idx
end
end
p = ta.delete_at(min_index)
# Update the element
p = {p[0] + b[(i + j) % n] // 2, p[1] + 1}
t = Math.max(t, p[1])
ta << p
end
ans = Math.min(ans, t)
end
puts ans
vjudge1