結果

問題 No.1173 Endangered Species
ユーザー risujiroh
提出日時 2020-08-14 23:24:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 2,783 ms
コンパイル使用メモリ 248,544 KB
最終ジャッジ日時 2025-01-13 00:45:58
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>

#ifndef DUMP
#define DUMP(...) (void)0
#endif

using namespace std;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vector<double> p(n), q(n);
  for (auto&& e : p) cin >> e;
  for (auto&& e : q) cin >> e;
  auto chk = [&](double m) {
    double sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += p[i] * (1 - q[i]) / (1 - q[i] * m);
    }
    return sum > m;
  };
  double ok = 0, ng = 1;
  for (int _ = 100; _--;) {
    double mid = (ok + ng) / 2;
    (chk(mid) ? ok : ng) = mid;
  }
  DUMP(ok);
  double res = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    res += log((1 - q[i]) / (1 - q[i] * ok)) * a;
  }
  cout << res << '\n';
}
0