F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Bathysphere

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1009    Accepted Submission(s): 238


Problem Description
The Bathysphere is a spherical deep-sea submersible which was unpowered and lowered into the ocean on a cable, and was used to conduct a series of dives under the sea. The Bathysphere was designed for studying undersea wildlife.

The Bathysphere was conducted from the deck of a ship. After counted, the ship should not move, so choosing the position where the Bathysphere was conducted is important.

A group of scientists want to study the secrets of undersea world along the equator, and they would like to use the Bathysphere. They want to choose the position where the Bathysphere can dive as deep as possible. Before conducting the Bathysphere, they have a map of the seabed, which tell them the shape of the seabed. They draw a line on the equator of the map to mark where they will release the Bathysphere, as a number axis. Suppose the axis is draw from 0 to L. But when they release the Bathysphere, they can't know where they are accurately, i.e., if they choose position x to release the Bathysphere, the real position will distribute between x-d and x+d with an equal probability, where d is given. The objective of the scientists is very simple, i.e., to maximize the expected depth.

For the ease of presentation, the shape of the seabed is described as a poly line. Given N points ) , ( Xi,Yi ) as the vertices, where Xi and Yi indicate the position and the depth of the i-th vertex, respectively, the ploy line is composed of the line segments that connect consecutive vertices.
 

Input
The first line contains an integer T (1 ¡Ü T ¡Ü 25), the number of test cases.

Then T test cases follow. In each test case, the first line contains two integers N (2 ¡Ü N ¡Ü 2*10^5) and L (2 ¡Ü L ¡Ü 10^9), as described above. Then N lines follow, each line contains two integer Xi and Yi (1¡Üi¡ÜN, 0¡Ü Yi ¡Ü10^9), where point ( Xi,Yi ) is a vertex of the ploy line. It is assumed that X1 == 0 and Xn == L and Xi < Xi+1 for 1 ¡Ü i < N. Then the following line contains one integer d (0 ¡Ü d ¡Ü L/2), as described above.
 

Output
For each test case, choose a position between d and L-d, both inclusive, to conducted the Bathysphere, and calculate the expected depth. Output the expected depth in a line, rounded to 3 digits after the decimal point.
 

Sample Input
2 3 10 0 3 4 10 10 1 5 3 10 0 3 4 10 10 1 1
 

Sample Output
5.900 9.192
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-26 17:36:19, Gzip enabled