結果
| 問題 |
No.1173 Endangered Species
|
| コンテスト | |
| ユーザー |
anagohirame
|
| 提出日時 | 2020-08-14 23:35:21 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 476 bytes |
| コンパイル時間 | 427 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 145,808 KB |
| 最終ジャッジ日時 | 2024-10-10 16:52:02 |
| 合計ジャッジ時間 | 7,404 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 TLE * 1 |
| other | AC * 14 TLE * 5 |
ソースコード
from math import log from scipy import optimize n = int(input()) p = list(map(float, input().split())) q = list(map(float, input().split())) a = list(map(int, input().split())) def f(x): return sum(p[i] * (1-q[i]) / (1-q[i]*x) for i in range(n)) - x def f_prime(x): return sum(p[i] * (1/q[i] - 1) / ((1/q[i] - x)**2) for i in range(n)) - 1 r = optimize.newton(f, 0, fprime=f_prime) #print(r) ans = 0 for i in range(n): ans += a[i] * log((1-q[i]) / (1-q[i]*r)) print(ans)
anagohirame