結果

問題 No.1173 Endangered Species
ユーザー KudeKude
提出日時 2020-08-15 04:39:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 1,684 ms
コンパイル使用メモリ 166,280 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-04-18 23:37:37
合計ジャッジ時間 3,515 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 15 ms
5,376 KB
testcase_15 AC 12 ms
5,376 KB
testcase_16 AC 104 ms
5,376 KB
testcase_17 AC 162 ms
6,144 KB
testcase_18 AC 193 ms
6,656 KB
testcase_19 AC 193 ms
6,656 KB
testcase_20 AC 186 ms
6,528 KB
testcase_21 AC 190 ms
6,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
    int n;
    cin >> n;
    vector<double> p(n), q(n);
    VI a(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    rep(i, n) cin >> a[i];
    double l = 0, r = 1;
    rep(_, 300) {
        double c = (l + r) / 2;
        double s = 0;
        rep(i, n) s += p[i] * (1 - q[i]) / (1 - c * q[i]);
        (c < s ? l : r) = c;
    }
    vector<double> e(n);
    rep(i, n) {
        e[i] = log(1-q[i]) - log(1-l*q[i]);
    }
    double ans = 0;
    rep(i, n) ans += a[i] * e[i];
    printf("%.10f\n", ans);
}
0