結果
問題 | No.1173 Endangered Species |
ユーザー |
![]() |
提出日時 | 2020-08-15 04:39:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 198 ms / 2,000 ms |
コード長 | 788 bytes |
コンパイル時間 | 1,572 ms |
コンパイル使用メモリ | 171,448 KB |
実行使用メモリ | 6,656 KB |
最終ジャッジ日時 | 2024-10-10 17:10:28 |
合計ジャッジ時間 | 3,574 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#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);}