結果

問題 No.1173 Endangered Species
ユーザー optopt
提出日時 2020-05-09 16:14:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 2,176 ms
コンパイル使用メモリ 201,256 KB
実行使用メモリ 5,688 KB
最終ジャッジ日時 2023-09-19 09:02:58
合計ジャッジ時間 4,139 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 13 ms
4,376 KB
testcase_15 AC 10 ms
4,376 KB
testcase_16 AC 78 ms
4,388 KB
testcase_17 AC 121 ms
4,780 KB
testcase_18 AC 149 ms
4,976 KB
testcase_19 AC 148 ms
5,080 KB
testcase_20 AC 148 ms
5,688 KB
testcase_21 AC 148 ms
5,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<int(n); ++i)


int main() {
  int n; cin >> n;
  vector<double> p(n), q(n);
  vector<int> a(n); 
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  rep(i, n) cin >> a[i];

  auto fun = [&] (double y) {
    double f = 0;
    rep(i, n) f += p[i] * (1-q[i]) / (1-q[i]*y);
    return (f <= y);
  };

  double ok = 1;
  double ng = 0;
  rep(i, 30) {
    double md = (ok + ng) / 2;
    if (fun(md)) ok = md;
    else ng = md;
  }

  double ans = 0;
  rep(i, n) ans += a[i] * log((1-q[i]) / (1-q[i]*ok));
  cout << ans << endl;
  return 0;
}
0