結果

問題 No.1173 Endangered Species
ユーザー optopt
提出日時 2020-04-27 17:49:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,014 bytes
コンパイル時間 2,296 ms
コンパイル使用メモリ 201,964 KB
実行使用メモリ 7,088 KB
最終ジャッジ日時 2023-09-19 07:25:33
合計ジャッジ時間 6,219 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define rep(i, n) rep2(i, 0, n)
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vld = vector<ld>;

int main() {
  ll n; cin >> n;
  Vld p(n), q(n);
  V a(n); 
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  rep(i, n) cin >> a[i];

// assert //
  const ld EPS = 1e-13;
  assert(n >= 1 && n <= 1000);
  ld sum = 0;
  rep(i, n) {
    assert(p[i] + EPS >= 0 && p[i] - EPS <= 1);
    sum += p[i];
    assert(q[i] + EPS >= 0.1 && q[i] - EPS <= 0.9);
    assert(a[i] >= 0 && a[i] <= 10);
  }
  assert(sum - EPS <= 1 && sum + EPS >= 1);
/////////// 

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

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

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