結果

問題 No.1173 Endangered Species
ユーザー optopt
提出日時 2020-04-29 02:01:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 4,267 ms
コンパイル使用メモリ 201,440 KB
実行使用メモリ 6,780 KB
最終ジャッジ日時 2023-09-19 07:26:43
合計ジャッジ時間 4,602 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 3 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 15 ms
4,380 KB
testcase_15 AC 11 ms
4,380 KB
testcase_16 AC 92 ms
5,164 KB
testcase_17 AC 144 ms
6,076 KB
testcase_18 AC 176 ms
6,780 KB
testcase_19 AC 176 ms
6,672 KB
testcase_20 AC 174 ms
6,620 KB
testcase_21 AC 175 ms
6,668 KB
権限があれば一括ダウンロードができます

ソースコード

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 ld = long double;
using V = vector<int>;
using Vld = vector<ld>;

int main() {
  int 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];

  ld y = 0;
  rep(i, 100) {
    ld f = 0;
    rep(i, n) f += p[i] * (1-q[i]) / (1-q[i]*y);
    y = f;
  }

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