ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 25280 |
문제명 | Marathon |
레벨 | 골드 5 |
분류 |
이분 탐색 |
시간복잡도 | O(n*log(m*e)) |
인풋사이즈 | n<=10^5, m<=10^5, e<=10^6 |
사용한 언어 | Python 3.11 |
제출기록 | 63980KB / 436ms |
최고기록 | 436ms |
해결날짜 | 2023/08/01 |
"""Solution code for "BOJ 25280. Marathon".
- Problem link: https://www.acmicpc.net/problem/25280
- Solution link: http://www.teferi.net/ps/problems/boj/25280
Tags: [binary search]
"""
import functools
import sys
from teflib import binsearch
MUL = 10**6
def is_valid(x, ranges):
prob = 1.0
for a, b in ranges:
if x >= a:
prob *= (b - x) / (b - a)
if prob < 0.5:
return False
return True
def main():
N = int(sys.stdin.readline()) # pylint: disable=unused-variable
a_and_b = [
[float(x) for x in sys.stdin.readline().split()] for _ in range(N)
]
ranges = [(int(a * MUL), int(b * MUL)) for a, b in a_and_b]
beg, end = min(ranges)
answer = binsearch.maximum_valid_integer(
beg, end, functools.partial(is_valid, ranges=ranges)
)
print(answer / MUL)
if __name__ == '__main__':
main()