結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー atetubouatetubou
提出日時 2014-11-16 23:40:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 428 ms / 5,000 ms
コード長 1,585 bytes
コンパイル時間 1,688 ms
コンパイル使用メモリ 152,896 KB
実行使用メモリ 10,820 KB
最終ジャッジ日時 2023-08-30 07:48:58
合計ジャッジ時間 13,585 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 428 ms
10,016 KB
testcase_01 AC 424 ms
9,280 KB
testcase_02 AC 426 ms
9,964 KB
testcase_03 AC 413 ms
10,820 KB
testcase_04 AC 421 ms
10,472 KB
testcase_05 AC 412 ms
9,344 KB
testcase_06 AC 416 ms
9,520 KB
testcase_07 AC 425 ms
10,420 KB
testcase_08 AC 407 ms
8,764 KB
testcase_09 AC 412 ms
10,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef ll li;
typedef pair<ll,ll> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i, n) rep (i, n)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) (a).begin(),(a).end()
#define FLL(a,b) memset((a),b,sizeof(a))
#define CLR(a) memset((a),0,sizeof(a))
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
#define FORR(it,a) for(__typeof(a.rbegin())it=a.rbegin();it!=a.rend();++it)
template<typename T,typename U> ostream& operator<< (ostream& out, const pair<T,U>& val){return out << "(" << val.F << ", " << val.S << ")";}
template<class T> ostream& operator<< (ostream& out, const vector<T>& val){out << "{";rep(i,SZ(val)) out << (i?", ":"") << val[i];return out << "}";}
#define declare(a,it) __typeof(a) it=a
const double EPS = 1e-8;

const int dx[]={1,0,-1,0,1,1,-1,-1,0};
const int dy[]={0,1,0,-1,-1,1,-1,1,0};

int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];

  priority_queue<pair<double,int> > q;
  rep(i,n) q.push(mp(l[i],1));
  vector<double> ans;
  while(SZ(ans)<=5e5+10){
    double cc = q.top().F;
    int cv = q.top().S;
    q.pop();
    ans.pb(cc);
    q.push(mp(cc*cv/(cv+1),cv+1));
  }
  
  {
    int q;
    cin >> q;
    rep(i,q){
      int k;
      cin >> k;
      printf("%.18f\n",ans[k-1]);
      //cout << ans[k-1] << endl;
    }
  }
}
0