結果
| 問題 | No.68 よくある棒を切る問題 (2) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-11-21 03:54:31 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 242 ms / 5,000 ms | 
| コード長 | 733 bytes | 
| コンパイル時間 | 1,966 ms | 
| コンパイル使用メモリ | 199,112 KB | 
| 最終ジャッジ日時 | 2025-01-06 17:04:16 | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 | 
ソースコード
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
struct F
{
    ll a, b;
};
bool operator<(const F& f1, const F& f2) { return f1.a * f2.b < f1.b * f2.a; }
int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int N;
    std::cin >> N;
    std::priority_queue<F> q;
    for (int i = 0, L; i < N; i++) { std::cin >> L, q.push({L, 1}); }
    int Q;
    std::vector<ld> ans(500001);
    for (int cnt = 1; cnt <= 500000; cnt++) {
        const auto p = q.top();
        q.pop(), ans[cnt] = p.a * 1.0 / p.b, q.push({p.a, p.b + 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;
}
            
            
            
        