結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー face4face4
提出日時 2019-12-07 21:49:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 418 ms / 5,000 ms
コード長 606 bytes
コンパイル時間 697 ms
コンパイル使用メモリ 80,248 KB
実行使用メモリ 8,660 KB
最終ジャッジ日時 2023-08-27 03:26:47
合計ジャッジ時間 12,047 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 416 ms
8,600 KB
testcase_01 AC 414 ms
8,488 KB
testcase_02 AC 418 ms
8,660 KB
testcase_03 AC 402 ms
8,596 KB
testcase_04 AC 401 ms
8,472 KB
testcase_05 AC 415 ms
8,596 KB
testcase_06 AC 412 ms
8,332 KB
testcase_07 AC 414 ms
8,656 KB
testcase_08 AC 401 ms
8,336 KB
testcase_09 AC 401 ms
8,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 面白い
#include<iostream>
#include<queue>
#include<iomanip>
using namespace std;

double pre[500001];

int main(){
    int n;
    cin >> n;
    priority_queue<pair<double,int>> pq;
    for(int i = 0; i < n; i++){
        int x;  cin>> x;
        pq.push({x, 1});
    }
    for(int i = 1; i <= 500000; i++){
        pair<double,int> p = pq.top();  pq.pop();
        pre[i] = p.first;
        pq.push({p.first*p.second/(p.second+1), p.second+1});
    }
    int q;
    cin >> q;
    while(q--){
        int k;  cin >> k;
        cout << fixed << setprecision(12) << pre[k] << endl;
    }
    return 0;
}
0