結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー なおなお
提出日時 2014-11-17 00:40:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 441 ms / 5,000 ms
コード長 762 bytes
コンパイル時間 1,209 ms
コンパイル使用メモリ 151,012 KB
実行使用メモリ 9,740 KB
最終ジャッジ日時 2023-08-30 08:47:10
合計ジャッジ時間 7,603 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 441 ms
9,596 KB
testcase_01 AC 430 ms
9,596 KB
testcase_02 AC 431 ms
9,740 KB
testcase_03 AC 424 ms
9,528 KB
testcase_04 AC 420 ms
9,424 KB
testcase_05 AC 420 ms
9,600 KB
testcase_06 AC 425 ms
9,144 KB
testcase_07 AC 427 ms
9,064 KB
testcase_08 AC 409 ms
9,124 KB
testcase_09 AC 421 ms
9,264 KB
権限があれば一括ダウンロードができます

ソースコード

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