結果
問題 | No.9 モンスターのレベル上げ |
ユーザー | gigurururu |
提出日時 | 2015-01-29 18:21:41 |
言語 | Ruby (3.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 979 bytes |
コンパイル時間 | 602 ms |
コンパイル使用メモリ | 11,360 KB |
実行使用メモリ | 29,936 KB |
最終ジャッジ日時 | 2023-09-05 07:44:24 |
合計ジャッジ時間 | 14,714 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 108 ms
28,676 KB |
testcase_01 | AC | 109 ms
28,696 KB |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | AC | 355 ms
29,468 KB |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | AC | 92 ms
29,332 KB |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
コンパイルメッセージ
Syntax OK
ソースコード
n=gets.to_i bs=11 bmask=(1<< bs)-1 pq_base=[nil] gets.split.each.with_index(1){|j,i| a=j.to_i<< bs 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<< bs)+1} counts = [] pids = {} max_procs = 2 (1..n).each{|i| if pids.size >= max_procs pid = Process.wait counts << pids[pid].gets.to_i pids[pid].close pids.delete(pid) end read, write = IO.pipe pid = fork{ read.close pq=pq_base el.rotate(i).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/=2 while i>1 && d<pq[i]=pq[i/2] pq[i]=d } write.puts(pq[1..-2].map{|x|x&bmask}.max) write.close } if pids.key?(pid) counts << pids[pid].gets.to_i pids[pid].close else pids[pid] = read end } Process.waitall.each do |pst| counts << pids[pst[0]].gets.to_i end puts counts.min