結果

問題 No.9 モンスターのレベル上げ
ユーザー gigurururugigurururu
提出日時 2015-01-29 19:14:13
言語 Ruby
(3.2.2)
結果
AC  
実行時間 4,881 ms / 5,000 ms
コード長 547 bytes
コンパイル時間 54 ms
コンパイル使用メモリ 11,580 KB
実行使用メモリ 31,916 KB
最終ジャッジ日時 2023-09-06 03:33:56
合計ジャッジ時間 26,213 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,160 KB
testcase_01 AC 80 ms
15,292 KB
testcase_02 AC 2,248 ms
31,784 KB
testcase_03 AC 1,172 ms
29,260 KB
testcase_04 AC 984 ms
22,748 KB
testcase_05 AC 715 ms
20,644 KB
testcase_06 AC 275 ms
16,936 KB
testcase_07 AC 79 ms
15,092 KB
testcase_08 AC 318 ms
17,720 KB
testcase_09 AC 1,989 ms
31,764 KB
testcase_10 AC 76 ms
15,256 KB
testcase_11 AC 2,831 ms
31,676 KB
testcase_12 AC 4,881 ms
31,916 KB
testcase_13 AC 2,648 ms
31,792 KB
testcase_14 AC 2,026 ms
31,764 KB
testcase_15 AC 2,025 ms
31,120 KB
testcase_16 AC 107 ms
15,416 KB
testcase_17 AC 1,373 ms
25,556 KB
testcase_18 AC 1,148 ms
23,804 KB
testcase_19 AC 97 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<< 11)
  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<< 11)+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) & 0x7FF
    max=x if max<x
    break if min<x
  }
  min=max if min>max
}
p min
0