結果

問題 No.210 探し物はどこですか?
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-09-15 22:21:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 725 ms / 2,000 ms
コード長 1,654 bytes
コンパイル時間 1,694 ms
コンパイル使用メモリ 172,680 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-10 20:43:40
合計ジャッジ時間 12,088 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
4,380 KB
testcase_01 AC 74 ms
4,384 KB
testcase_02 AC 85 ms
4,376 KB
testcase_03 AC 383 ms
4,380 KB
testcase_04 AC 364 ms
4,380 KB
testcase_05 AC 317 ms
4,376 KB
testcase_06 AC 176 ms
4,380 KB
testcase_07 AC 367 ms
4,380 KB
testcase_08 AC 298 ms
4,380 KB
testcase_09 AC 314 ms
4,508 KB
testcase_10 AC 310 ms
4,380 KB
testcase_11 AC 368 ms
4,384 KB
testcase_12 AC 379 ms
4,380 KB
testcase_13 AC 249 ms
4,380 KB
testcase_14 AC 301 ms
4,380 KB
testcase_15 AC 677 ms
4,380 KB
testcase_16 AC 361 ms
4,380 KB
testcase_17 AC 725 ms
4,384 KB
testcase_18 AC 67 ms
4,376 KB
testcase_19 AC 68 ms
4,376 KB
testcase_20 AC 70 ms
4,380 KB
testcase_21 AC 68 ms
4,380 KB
testcase_22 AC 67 ms
4,376 KB
testcase_23 AC 109 ms
4,380 KB
testcase_24 AC 108 ms
4,380 KB
testcase_25 AC 110 ms
4,380 KB
testcase_26 AC 110 ms
4,380 KB
testcase_27 AC 106 ms
4,376 KB
testcase_28 AC 85 ms
4,376 KB
testcase_29 AC 87 ms
4,380 KB
testcase_30 AC 85 ms
4,380 KB
testcase_31 AC 83 ms
4,376 KB
testcase_32 AC 84 ms
4,380 KB
testcase_33 AC 121 ms
4,376 KB
testcase_34 AC 117 ms
4,380 KB
testcase_35 AC 119 ms
4,376 KB
testcase_36 AC 111 ms
4,380 KB
testcase_37 AC 111 ms
4,376 KB
testcase_38 AC 97 ms
4,380 KB
testcase_39 AC 97 ms
4,376 KB
testcase_40 AC 92 ms
4,376 KB
testcase_41 AC 94 ms
4,380 KB
testcase_42 AC 95 ms
4,380 KB
testcase_43 AC 18 ms
4,380 KB
testcase_44 AC 28 ms
4,380 KB
testcase_45 AC 352 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        auto i = vs.begin();
        os << "[" << *i;
        for (++i; i != vs.end(); ++i) os << " " << *i;
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    int N;
    vector<real> P, Q;
    void input() {
        cin >> N;
        P.resize(N); Q.resize(N);
        for (int i = 0; i < N; i++) {
            real p; cin >> p; p /= 1000;
            P[i] = p;
        }
        for (int i = 0; i < N; i++) {
            real q; cin >> q; q /= 100;
            Q[i] = q;
        }
    }

    struct S : pair<real, int> {
        S(real a, int b) : pair<real,int>(a, b) {}
        bool operator<(const S& o) const {
            return first * Q[second] < o.first * Q[o.second];
        }
    };

    void solve() {
        priority_queue<S> PQ;
        for (int i = 0; i < N; i++) PQ.emplace(P[i], i);
        real ans = 1.0;
        real mother = 1.0;
        for (int t = 1; t <= 1000000; t++) {
            auto pi = PQ.top(); PQ.pop();
            real p = pi.first;
            real index = pi.second;
            real q = Q[index];
            mother -= p * q;
            real np = p * (1.0 - q);
            ans += mother;
            PQ.emplace(np, index);
        }
        printf("%.12f\n", ans);
    }
}

int main() {
    input(); solve();
    return 0;
}

0