Orecart Boba Hard

시간 제한1초메모리 제한2048 MB

요약
두 사람이 각 정류장의 대기 시간을 지키며 오레카트와 동시에 도착할 수 있는 최소 이동 속도를 구한다.
난이도

어려움10점 중 8점

유형
이분 탐색, 그리디, 구현, 수학
정답자
아직 제출이 없습니다

문제

The only difference between this version and the easy version is that in this version, you must determine the minimum required speed vv yourself.

Eugin and Kelly are celebrating E-Days at the Colorado School of Mines by participating in the annual Orecart Pull. This is an event where everyone walks the Orecart down Colfax Avenue all the way to downtown Denver. Eugin and Kelly can go faster than the group, so they have decided to break off and grab boba from every stop along the route!

The walk is ll meters long, and the Orecart moves at a constant speed of 11 meter per second. Eugin and Kelly can run at a speed of at most vv meters per second, but they are not allowed to move ahead of the Orecart at any time.

There are nn boba stops along the route, the ii-th of which is located at distance d_id\_i along the route. Additionally, at the ii-th boba stop, they must wait at least w_iw\_i seconds to receive their boba before continuing.

Eugin and Kelly need to visit all nn boba stops while ensuring that they reach the end at exactly the same time as the Orecart. Determine the minimum required speed vv for them to accomplish this.

If it is impossible for any finite speed to allow them to reach the end on time, or if the required speed would need to exceed the speed of light (3⋅1083 \cdot 10^8 meters per second), output IMPOSSIBLE. Otherwise, print the minimum required speed vv with a relative error of at most 10−410^{-4}.

입력

The input consists of multiple lines:

  • The first line contains two integers nn and ll (1≤n≤105,2≤l≤108)(1 \leq n \leq 10^5, 2 \leq l \leq 10^8)---the number of boba stops and the length of the route.
  • The second line contains nn integers d_1,d_2,…,d_nd\_1, d\_2, \dots, d\_n (0<d_1<d_2<⋯<d_n<l)(0 < d\_1 < d\_2 < \dots < d\_n < l)---the distances at which each of the boba stops are located.
  • The third line contains nn integers w_1,w_2,…,w_nw\_1, w\_2, \dots, w\_n (0≤w_i≤108)(0 \leq w\_i \leq 10^8)---the waiting times at each boba stop.

출력

If it is impossible to reach the end on time no matter the speed, or if the required speed would need to exceed 3×1083 \times 10^8 meters per second, print IMPOSSIBLE. Otherwise, print the minimum required speed vv such that the relative error does not exceed 10−410^{-4}.

예제2

  1. 예제 1

    입력
    3 80
    20 40 60
    30 2 10
    
    예상 출력
    3.33333333
    
  2. 예제 2

    입력
    2 20
    5 15
    0 5
    
    예상 출력
    IMPOSSIBLE