結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー beet
提出日時 2018-11-27 20:43:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 509 ms / 5,000 ms
コード長 832 bytes
コンパイル時間 2,360 ms
コンパイル使用メモリ 201,972 KB
最終ジャッジ日時 2025-01-06 17:45:05
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<double> l(n);
  for(Int i=0;i<n;i++) cin>>l[i];
  using P = pair<double, Int>;
  priority_queue<P> pq;
  for(Int i=0;i<n;i++)
    pq.emplace(l[i],i);
  
  const Int MAX = 5e5+100;
  vector<double> dp(MAX);
  vector<Int> sz(n,1);
  for(Int i=1;i<MAX;i++){
    dp[i]=pq.top().first;
    Int k=pq.top().second;pq.pop();
    pq.emplace(l[k]/++sz[k],k);
  }
  
  Int q;
  cin>>q;
  while(q--){
    Int k;
    cin>>k;
    cout<<dp[k]<<endl;
  }
  return 0;
}
0