結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー letrangerjpletrangerjp
提出日時 2017-06-18 15:40:25
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 355 bytes
コンパイル時間 41 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 43,936 KB
最終ジャッジ日時 2024-04-09 19:53:12
合計ジャッジ時間 19,331 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,777 ms
38,272 KB
testcase_01 AC 2,721 ms
38,400 KB
testcase_02 AC 2,884 ms
38,272 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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