結果

問題 No.210 探し物はどこですか?
ユーザー tottoripapertottoripaper
提出日時 2019-03-09 09:55:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 1,129 bytes
コンパイル時間 1,763 ms
コンパイル使用メモリ 177,048 KB
実行使用メモリ 11,860 KB
最終ジャッジ日時 2023-09-05 19:48:09
合計ジャッジ時間 9,001 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
11,600 KB
testcase_01 AC 99 ms
11,784 KB
testcase_02 AC 103 ms
11,788 KB
testcase_03 AC 153 ms
11,796 KB
testcase_04 AC 145 ms
11,648 KB
testcase_05 AC 143 ms
11,600 KB
testcase_06 AC 152 ms
11,824 KB
testcase_07 AC 147 ms
11,600 KB
testcase_08 AC 102 ms
11,740 KB
testcase_09 AC 106 ms
11,692 KB
testcase_10 AC 108 ms
11,652 KB
testcase_11 AC 118 ms
11,600 KB
testcase_12 AC 119 ms
11,612 KB
testcase_13 AC 112 ms
11,600 KB
testcase_14 AC 146 ms
11,644 KB
testcase_15 AC 144 ms
11,660 KB
testcase_16 AC 140 ms
11,824 KB
testcase_17 AC 152 ms
11,600 KB
testcase_18 AC 86 ms
11,596 KB
testcase_19 AC 89 ms
11,792 KB
testcase_20 AC 91 ms
11,820 KB
testcase_21 AC 90 ms
11,596 KB
testcase_22 AC 90 ms
11,656 KB
testcase_23 AC 117 ms
11,672 KB
testcase_24 AC 119 ms
11,668 KB
testcase_25 AC 121 ms
11,840 KB
testcase_26 AC 120 ms
11,612 KB
testcase_27 AC 122 ms
11,616 KB
testcase_28 AC 131 ms
11,788 KB
testcase_29 AC 132 ms
11,776 KB
testcase_30 AC 132 ms
11,596 KB
testcase_31 AC 131 ms
11,848 KB
testcase_32 AC 130 ms
11,668 KB
testcase_33 AC 141 ms
11,804 KB
testcase_34 AC 139 ms
11,828 KB
testcase_35 AC 142 ms
11,628 KB
testcase_36 AC 140 ms
11,860 KB
testcase_37 AC 140 ms
11,628 KB
testcase_38 AC 139 ms
11,624 KB
testcase_39 AC 139 ms
11,688 KB
testcase_40 AC 137 ms
11,824 KB
testcase_41 AC 141 ms
11,848 KB
testcase_42 AC 139 ms
11,628 KB
testcase_43 AC 81 ms
11,656 KB
testcase_44 AC 40 ms
11,772 KB
testcase_45 AC 153 ms
11,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<double,int>;

int N;
double p[1000], q[1000], alpha = 1.0;
std::priority_queue<P> pq;
std::stack<double> st;

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> p[i];
        p[i] *= 1e-3;
    }

    for(int i=0;i<N;++i){
        std::cin >> q[i];
        q[i] *= 1e-2;
    }

    for(int i=0;i<N;++i){
        pq.emplace(p[i] * q[i], i);
    }

    for(int t=0;t<1'000'000;++t){
        double r;
        int i;
        std::tie(r, i) = pq.top();
        pq.pop();

        double s = r / alpha;

        st.emplace(s);

        if(s == 1){
            break;
        }

        alpha *= 1.0 - s;
        pq.emplace(r * (1.0 - q[i]), i);   
    }

    double e = 0;
    until(st.empty()){
        double s = st.top();
        st.pop();
        
        e = 1.0 + (1.0 - s) * e;
    }
    
    printf("%.5f\n", e);
}
0