Revenge of the Hot Dogs (Small)

Vendors on a line move at speed 1 and must end at least D apart, so find the smallest time that allows such positions.

Medium6Binary searchGreedySortingInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

Last year several hot dog vendors lined up along a street and ran an algorithm to spread themselves out. The algorithm was so slow that it is still running, so the vendors decided to try a new one.

The trouble is that vendors standing too close to each other take each other's business. A vendor moves along the street at 1 meter per second. To stay out of each other's way, they want to stand so that every pair of vendors is at least DD meters apart.

The street is very long, so no vendor ever runs out of room in either direction. Given the starting positions of all vendors, find the minimum time needed until every pair of vendors is at least DD meters apart. Several vendors can start at the same point, and each vendor can move east or west.

Input

Every point of the street carries an integer label. The point labeled pp is p|p| meters east of the point labeled 00 when pp is positive, and p|p| meters west of it when pp is negative.

The first line contains the number of test cases TT. Each test case begins with a line holding the number of points CC that have at least one vendor in the starting configuration and the minimum distance DD the vendors want between them, separated by a space. The next CC lines each hold two space separated integers PP and VV, meaning that VV vendors stand at the point labeled PP.

Limits

  • 1T501 \le T \le 50
  • 1C201 \le C \le 20
  • 1D51 \le D \le 5
  • 105P105-10^5 \le P \le 10^5
  • Within one test case all PP values are distinct and are given in increasing order.
  • VV is a positive integer, and the sum of the VV values in one test case is at most 100100.

Output

For each test case print one line in the form Case #x: y, where xx is the test case number starting from 1 and yy is the minimum time until every pair of vendors is at least DD meters apart.

The answer is always a multiple of 0.50.5, so print it with exactly one digit after the decimal point. An answer of 11 prints as 1.0, and an answer of 2.52.5 prints as 2.5.