結果

問題 No.1173 Endangered Species
ユーザー pockynypockyny
提出日時 2020-08-15 15:22:06
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 731 ms
コンパイル使用メモリ 81,772 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-04-19 01:13:38
合計ジャッジ時間 2,881 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 18 ms
5,376 KB
testcase_15 AC 13 ms
5,376 KB
testcase_16 AC 114 ms
6,400 KB
testcase_17 AC 180 ms
7,680 KB
testcase_18 AC 219 ms
8,576 KB
testcase_19 AC 215 ms
8,576 KB
testcase_20 AC 221 ms
8,576 KB
testcase_21 AC 223 ms
8,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
using namespace std;
typedef long double ld;
ld p[100010],q[100010],a[100010];
bool ch(int n,ld val){
    ld res = -val;
    for(int i=0;i<n;i++) res += p[i]*(1 - q[i])/(1 - q[i]*val);
    if(res>0) return false;
    return true;
}

int main(){
    cout.precision(20);
    int i,n; cin >> n;
    for(i=0;i<n;i++) cin >> p[i];
    for(i=0;i<n;i++) cin >> q[i];
    for(i=0;i<n;i++) cin >> a[i];
    ld l = 0,r = 0.9999999999999;
    for(i=0;i<=200;i++){
        ld mid = (l + r)/2;
        if(ch(n,mid)) r = mid;
        else l = mid;
    }
    ld ans = 0;
    for(i=0;i<n;i++){
        ans += a[i]*log((1 - q[i])/(1 - q[i]*r));
    }
    cout << ans << endl;
}
0