結果

問題 No.9 モンスターのレベル上げ
ユーザー gigurururugigurururu
提出日時 2015-01-29 19:06:17
言語 Ruby
(3.2.2)
結果
WA  
実行時間 -
コード長 511 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 11,460 KB
実行使用メモリ 31,892 KB
最終ジャッジ日時 2023-09-05 07:52:50
合計ジャッジ時間 32,947 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,128 KB
testcase_01 AC 82 ms
15,136 KB
testcase_02 AC 2,919 ms
31,720 KB
testcase_03 AC 2,370 ms
29,008 KB
testcase_04 AC 1,245 ms
22,864 KB
testcase_05 AC 861 ms
20,576 KB
testcase_06 AC 369 ms
17,164 KB
testcase_07 AC 89 ms
15,264 KB
testcase_08 AC 437 ms
17,652 KB
testcase_09 AC 2,820 ms
31,744 KB
testcase_10 AC 82 ms
15,112 KB
testcase_11 AC 2,869 ms
31,704 KB
testcase_12 WA -
testcase_13 AC 2,676 ms
31,728 KB
testcase_14 AC 2,895 ms
31,772 KB
testcase_15 AC 2,585 ms
30,860 KB
testcase_16 AC 124 ms
15,468 KB
testcase_17 AC 1,690 ms
25,432 KB
testcase_18 AC 1,430 ms
23,984 KB
testcase_19 AC 105 ms
15,352 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