結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー parukiparuki
提出日時 2016-10-06 22:48:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 269 ms / 5,000 ms
コード長 1,002 bytes
コンパイル時間 1,643 ms
コンパイル使用メモリ 173,660 KB
実行使用メモリ 9,820 KB
最終ジャッジ日時 2024-05-01 14:11:40
合計ジャッジ時間 6,348 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 269 ms
9,820 KB
testcase_01 AC 265 ms
9,820 KB
testcase_02 AC 263 ms
9,692 KB
testcase_03 AC 245 ms
9,820 KB
testcase_04 AC 246 ms
9,804 KB
testcase_05 AC 246 ms
9,816 KB
testcase_06 AC 259 ms
9,364 KB
testcase_07 AC 259 ms
9,536 KB
testcase_08 AC 240 ms
9,208 KB
testcase_09 AC 241 ms
9,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int MA = 100001, GOMA = 5 * MA;
int N, L[MA], Q, K, A[GOMA];
double ans[GOMA];

int main(){
    cin >> N;
    rep(i, N)scanf("%d", &L[i]);
    priority_queue<pair<double,int> > q;
    rep(i, N)q.push(mp(L[i], i)), A[i] = 1;
    FOR(i, 1, GOMA){
        double x;
        int k;
        tie(x, k) = q.top(); q.pop();
        ans[i] = x;
        q.push(mp((double)L[k] / ++A[k], k));
    }
    cin >> Q;
    while(Q--){
        scanf("%d", &K);
        printf("%0.15f\n", ans[K]);
    }
}
0