結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー Shibuyap
提出日時 2020-10-24 18:02:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 525 ms / 5,000 ms
コード長 964 bytes
コンパイル時間 2,514 ms
コンパイル使用メモリ 199,720 KB
最終ジャッジ日時 2025-01-15 15:10:03
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<double, int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
double f[600000] = {};
int main() {
    int n; cin >> n;
    double a[n];
    rep(i,n) cin >> a[i];
    int q;
    cin >> q;
    int b[q];
    rep(i,q) cin >> b[i];

    
    pair<P,int> p;
    priority_queue<pair<P,int>> que;
    rep(i,n){
        p.first.first = a[i];
        p.first.second = 1;
        p.second = i;
        que.push(p);
    }
    srep(i,1,600000){
        p = que.top();
        que.pop();
        f[i] = p.first.first;
        p.first.second++;
        p.first.first = a[p.second] / p.first.second;
        que.push(p);
    }   

    rep(i,q){
        cout << fixed << setprecision(10) << f[b[i]] << endl;
    }
    return 0;
}
 
 
0