結果

問題 No.9 モンスターのレベル上げ
ユーザー vjudge1
提出日時 2025-09-05 08:57:00
言語 Crystal
(1.14.0)
結果
WA  
実行時間 -
コード長 516 bytes
コンパイル時間 13,076 ms
コンパイル使用メモリ 309,040 KB
実行使用メモリ 11,424 KB
最終ジャッジ日時 2025-09-05 08:57:40
合計ジャッジ時間 38,869 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 2 TLE * 1 -- * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

n = gets.to_s.to_i
a = gets.to_s.split.map(&.to_i)
b = gets.to_s.split.map(&.to_i)

temp = a.map { |val| {val, 0} }
ans = 10**9

n.times do |i|
  heap = temp.dup
  ma = 0
  
  n.times do |j|
    # Get and remove the smallest element
    min_index = heap.index(heap.min_by { |pair| pair[0] }).not_nil!
    t, u = heap.delete_at(min_index)
    
    new_val = t + b[(i + j) % n] // 2
    new_pair = {new_val, u + 1}
    heap << new_pair
    
    ma = Math.max(ma, u + 1)
  end
  
  ans = Math.min(ans, ma)
end

puts ans
0