結果
問題 |
No.2009 Drunkers' Contest
|
ユーザー |
![]() |
提出日時 | 2022-07-15 22:04:05 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,303 bytes |
コンパイル時間 | 207 ms |
コンパイル使用メモリ | 82,712 KB |
実行使用メモリ | 142,808 KB |
最終ジャッジ日時 | 2024-06-27 18:03:43 |
合計ジャッジ時間 | 17,930 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 8 WA * 34 TLE * 1 -- * 11 |
ソースコード
#!/usr/bin/env PyPy3 from collections import Counter, defaultdict, deque import itertools import re import math from functools import reduce import operator import bisect from heapq import * import functools mod=998244353 import sys input=sys.stdin.readline n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) flg = [0] * n ma = 0 for i in range(n): if ma < a[i] / b[i]: ma = a[i] / b[i] flg[i] = 1 ans = 0 l = -1 now = 1 def f(x,l,r): res = 0 for i in range(l,r): res += a[i] / x + b[i] * x return res for i in range(n): if flg[i]: if l == -1: l = i else: high = 10 ** 5 low = now while high - low > (10 ** (-12)): l1 = low + (high - low) / 3 l2 = high - (high - low) / 3 if f(l1,l,i) > f(l2,l,i): low = l1 else: high = l2 ans += f((high+low)/2,l,i) l = i now = (high+low)/2 high = 10 ** 5 low = now while high - low > (10 ** (-12)): l1 = low + (high - low) / 3 l2 = high - (high - low) / 3 if f(l1,l,n) > f(l2,l,n): low = l1 else: high = l2 ans += f((high+low)/2,l,n) print(ans)