結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー なお
提出日時 2014-11-17 00:40:48
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 455 ms / 5,000 ms
コード長 762 bytes
コンパイル時間 1,512 ms
コンパイル使用メモリ 161,916 KB
実行使用メモリ 9,884 KB
最終ジャッジ日時 2025-01-01 19:55:23
合計ジャッジ時間 8,012 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))

int L[100010],D[100010];
double K[500010];

int main(){
    int N; cin >> N;
    REP(i,N) cin >> L[i];

    priority_queue<pair<double,int> > q;
    REP(i,N){
        q.push(make_pair(L[i],i));
        D[i] = 1;
    }
    REP(i,500001){
        auto v = q.top(); q.pop();
        int j = v.second; // index;
        double k = v.first; // L[j]/D[j]
        K[i+1] = k;
        D[j]++;
        q.push(make_pair(1.*L[j]/D[j],j));
    }

    ll Q; cin >> Q;
    REP(i,Q){
        int Ki; cin >> Ki;
        cout << fixed << setprecision(15) << K[Ki] << endl;
    }
    return 0;
}
0