結果

問題 No.210 探し物はどこですか?
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-09-15 22:20:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,653 bytes
コンパイル時間 1,486 ms
コンパイル使用メモリ 174,416 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 13:54:46
合計ジャッジ時間 2,986 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 31 ms
5,376 KB
testcase_04 AC 16 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 16 ms
5,376 KB
testcase_07 AC 17 ms
5,376 KB
testcase_08 AC 5 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 5 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 9 ms
5,376 KB
testcase_14 AC 10 ms
5,376 KB
testcase_15 AC 10 ms
5,376 KB
testcase_16 AC 11 ms
5,376 KB
testcase_17 AC 11 ms
5,376 KB
testcase_18 AC 9 ms
5,376 KB
testcase_19 AC 8 ms
5,376 KB
testcase_20 AC 9 ms
5,376 KB
testcase_21 AC 9 ms
5,376 KB
testcase_22 AC 9 ms
5,376 KB
testcase_23 AC 12 ms
5,376 KB
testcase_24 AC 13 ms
5,376 KB
testcase_25 AC 12 ms
5,376 KB
testcase_26 AC 12 ms
5,376 KB
testcase_27 AC 12 ms
5,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 13 ms
5,376 KB
testcase_34 AC 13 ms
5,376 KB
testcase_35 AC 13 ms
5,376 KB
testcase_36 AC 13 ms
5,376 KB
testcase_37 AC 13 ms
5,376 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 3 ms
5,376 KB
testcase_44 AC 4 ms
5,376 KB
testcase_45 AC 31 ms
5,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 <= 100000; 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