結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー mamekinmamekin
提出日時 2015-01-17 08:42:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 404 ms / 5,000 ms
コード長 1,008 bytes
コンパイル時間 2,368 ms
コンパイル使用メモリ 98,352 KB
実行使用メモリ 9,460 KB
最終ジャッジ日時 2023-09-04 16:56:11
合計ジャッジ時間 13,950 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 400 ms
9,324 KB
testcase_01 AC 401 ms
9,380 KB
testcase_02 AC 404 ms
9,284 KB
testcase_03 AC 399 ms
9,284 KB
testcase_04 AC 404 ms
9,400 KB
testcase_05 AC 400 ms
9,460 KB
testcase_06 AC 392 ms
8,796 KB
testcase_07 AC 401 ms
8,988 KB
testcase_08 AC 393 ms
8,836 KB
testcase_09 AC 400 ms
8,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> len(n);
    for(int i=0; i<n; ++i)
        cin >> len[i];

    priority_queue<pair<double, int> > pq;
    for(int i=0; i<n; ++i)
        pq.push(make_pair(len[i], i));
    
    vector<int> cnt(n, 0);
    vector<double> ret(500001);
    for(int i=1; i<=500000; ++i){
        ret[i] = pq.top().first;
        int j = pq.top().second;
        pq.pop();

        ++ cnt[j];
        pq.push(make_pair(len[j] / (cnt[j] + 1.0), j));
    }

    int q;
    cin >> q;
    while(--q >= 0){
        int k;
        cin >> k;
        printf("%.10f\n", ret[k]);
    }

    return 0;
}
0