結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー PachicobuePachicobue
提出日時 2018-11-21 03:43:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 333 ms / 5,000 ms
コード長 814 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 206,472 KB
実行使用メモリ 17,592 KB
最終ジャッジ日時 2023-08-26 02:34:11
合計ジャッジ時間 13,027 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 329 ms
16,840 KB
testcase_01 AC 329 ms
16,140 KB
testcase_02 AC 333 ms
16,588 KB
testcase_03 AC 313 ms
16,480 KB
testcase_04 AC 312 ms
16,312 KB
testcase_05 AC 316 ms
16,500 KB
testcase_06 AC 324 ms
15,904 KB
testcase_07 AC 328 ms
16,764 KB
testcase_08 AC 306 ms
16,868 KB
testcase_09 AC 308 ms
17,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
using ll = long long;
using ld = long double;
int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int N;
    std::cin >> N;
    std::vector<ll> L(N);
    for (int i = 0; i < N; i++) { std::cin >> L[i]; }
    int Q;
    std::vector<ld> ans(500001);
    using P = std::pair<ld, int>;
    std::priority_queue<P> q;
    for (int i = 0; i < N; i++) { q.push({L[i], 1}); }
    for (int cnt = 1; cnt <= 500000; cnt++) {
        const auto p = q.top();
        q.pop(), ans[cnt] = p.first, q.push({p.first * p.second / (p.second + 1), p.second + 1});
    }
    std::cin >> Q;
    for (int q = 0, K; q < Q; q++) { std::cin >> K, std::cout << std::fixed << std::setprecision(15) << ans[K] << "\n"; }
    return 0;
}
0