結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー letrangerjpletrangerjp
提出日時 2017-06-18 15:34:33
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 355 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 37,884 KB
最終ジャッジ日時 2024-04-09 19:51:26
合計ジャッジ時間 32,998 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
L = gets.split.take(N).map(&:to_i)
Q = gets.to_i
K = gets.split.take(Q).map(&:to_i)

pq = L.map.with_index{|l, i|[l, i, 1.0]}.sort
res = [0]
K.max.times{
  l, i, div = pq.pop
  res << l
  div1 = div + 1
  l1 = L[i] / div1
  new_item = [l1, i, div1]
  pq[pq.bsearch_index{|v,_,_| v < l1 }||pq.size, 0] = [new_item]
}

K.each{|i|
  p res[i]
}
0