結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー beetbeet
提出日時 2018-11-27 20:43:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 436 ms / 5,000 ms
コード長 832 bytes
コンパイル時間 2,248 ms
コンパイル使用メモリ 208,000 KB
実行使用メモリ 10,268 KB
最終ジャッジ日時 2023-09-06 06:17:37
合計ジャッジ時間 13,610 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 436 ms
10,180 KB
testcase_01 AC 428 ms
10,076 KB
testcase_02 AC 434 ms
10,216 KB
testcase_03 AC 429 ms
10,080 KB
testcase_04 AC 425 ms
10,164 KB
testcase_05 AC 428 ms
10,268 KB
testcase_06 AC 428 ms
9,704 KB
testcase_07 AC 426 ms
9,892 KB
testcase_08 AC 410 ms
9,452 KB
testcase_09 AC 421 ms
9,744 KB
権限があれば一括ダウンロードができます

ソースコード

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