結果

問題 No.9 モンスターのレベル上げ
ユーザー gigurururugigurururu
提出日時 2015-01-29 19:05:29
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 511 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 11,248 KB
実行使用メモリ 31,868 KB
最終ジャッジ日時 2023-09-05 07:48:55
合計ジャッジ時間 32,299 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,208 KB
testcase_01 AC 81 ms
15,220 KB
testcase_02 AC 2,896 ms
31,756 KB
testcase_03 AC 2,280 ms
28,988 KB
testcase_04 AC 1,237 ms
22,840 KB
testcase_05 AC 848 ms
20,340 KB
testcase_06 AC 347 ms
17,124 KB
testcase_07 AC 86 ms
15,140 KB
testcase_08 AC 441 ms
17,636 KB
testcase_09 AC 2,857 ms
31,764 KB
testcase_10 AC 80 ms
15,080 KB
testcase_11 AC 2,870 ms
31,836 KB
testcase_12 WA -
testcase_13 AC 2,707 ms
31,732 KB
testcase_14 AC 2,867 ms
31,624 KB
testcase_15 AC 2,567 ms
31,108 KB
testcase_16 AC 124 ms
15,392 KB
testcase_17 AC 1,710 ms
25,288 KB
testcase_18 AC 1,439 ms
23,880 KB
testcase_19 AC 105 ms
15,224 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
pq_base=[nil]
gets.split.each.with_index(1){|j,i|
  a=j.to_i<<8
  i/=2 while i>1 && a<pq_base[i]=pq_base[i/2]
  pq_base[i]=a
}
pq_base<<1e9

el=gets.split.map{|i|(i.to_i/2<<8)+1}
min=1e9
n.times{
  max=0
  pq=pq_base.dup
  el.rotate!.each{|e|
    a=pq[n]
    d=pq[i=1]+e
    while (c=i*2)<n
      c+=1 if pq[c]>pq[c+1]
      break if a<=pq[i]=pq[c]
      i=c
    end
    pq[i]=a
    i=n
    i>>=1 while i>1 && d<pq[i]=pq[i>>1]
    x=(pq[i]=d)&0xFF
    max=x if max<x
  }
  min=max if min>max
}
p min
0