結果
| 問題 |
No.1173 Endangered Species
|
| コンテスト | |
| ユーザー |
opt
|
| 提出日時 | 2020-05-09 16:14:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 195 ms / 2,000 ms |
| コード長 | 615 bytes |
| コンパイル時間 | 2,569 ms |
| コンパイル使用メモリ | 197,212 KB |
| 最終ジャッジ日時 | 2025-01-10 09:52:28 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#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;
}
opt