結果

問題 No.9 モンスターのレベル上げ
ユーザー gigurururugigurururu
提出日時 2015-01-29 20:32:05
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 726 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 11,232 KB
実行使用メモリ 31,944 KB
最終ジャッジ日時 2023-09-06 03:35:21
合計ジャッジ時間 30,978 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,072 KB
testcase_01 AC 82 ms
15,348 KB
testcase_02 AC 2,663 ms
31,856 KB
testcase_03 AC 1,384 ms
28,860 KB
testcase_04 AC 1,161 ms
22,940 KB
testcase_05 AC 834 ms
20,180 KB
testcase_06 AC 319 ms
17,156 KB
testcase_07 AC 84 ms
15,100 KB
testcase_08 AC 376 ms
17,528 KB
testcase_09 AC 2,354 ms
31,672 KB
testcase_10 AC 80 ms
15,132 KB
testcase_11 AC 3,428 ms
31,732 KB
testcase_12 TLE -
testcase_13 AC 3,234 ms
31,784 KB
testcase_14 AC 2,432 ms
31,900 KB
testcase_15 AC 2,428 ms
31,004 KB
testcase_16 AC 117 ms
15,416 KB
testcase_17 AC 1,612 ms
25,332 KB
testcase_18 AC 1,359 ms
23,868 KB
testcase_19 AC 104 ms
15,132 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class BinHeap
  def initialize(buf=nil)
    @buf=buf||[nil]
    @max=@buf.size
  end
  def add(n)
    a=n
    i=@max
    @max+=1
    i>>=1 while i>1 && a<@buf[i]=@buf[i>>1]
    @buf[i]=a
  end
  def get
    ret=@buf[1]
    a=@buf[l=@max-=i=1]
    while (c=i*2)<l
      c+=1 if @buf[c]>(@buf[c+1]||1e9)
      break if a<=@buf[i]=@buf[c]
      i=c
    end
    @buf[i]=a
    ret
  end
  def dup
    BinHeap.new(@buf[0..@max-1])
  end
end
n=gets.to_i
pq_base=BinHeap.new
gets.split.each{|i|pq_base.add(i.to_i<<11)}
b=gets.split.map{|i|i.to_i/2<<11}
min=1e9
n.times{
  pq=pq_base.dup
  max=0
  b.rotate!.each{|e|
    pq.add(top=pq.get+e+1)
    top&=0x7FF
    max=top if max<top
    break if min<top
  }
  min=max if min>max
}
p min
0