프로그램 명: boi_subway(special judge)
제한시간: 2 초
//sj 가 아직 ...

The subway in Stockholm consists of several subway lines. In this problem we will consider one line in particular, and the problems that quite often happens on it when there’s been a “signalling error”. A subway line can be seen as two parallel rails connected at the endpoints. In the upper rail the trains are going from right to left and in the lower rail the trains are going from left to right. When a train reaches an endpoint of a rail, it switches to the opposite rail and changes direction. This switch is instantaneous and takes no time.

During normal traffic, the traffic flow is continuous and the trains are moving at a constant speed (1 length unit per time unit). The trains are evenly distributed; that is, at any given position on a rail, the trains will appear periodically. We will assume that the time it takes for a train to stop and pick up passengers is negligible.

Now, because of signalling errors, the trains have been randomly distributed along the line. Your job as the traffic manager is to, as fast as possible, ensure that the trains will be evenly distributed along the line again. Write a program that, given the current train positions, calculates how fast this can be achieved. You are allowed to order the trains to temporarily stop, and/or change direction anywhere along the line. If a train changes direction, it will move from one rail to the other.

입력

출력

Your program should output a single line to standard output, containing the shortest time it takes to make the trains evenly distributed. Your program should have an absolute precision error of at most 10^-6.

입출력 예

입력

100 5
5 R
35 L
46 L
75 L
85 R

출력

0.5

입력

100 8
9 L
15 R
41 L
33 L
81 R
33 R
100 L
97 R

출력

15.500000

Constraints

출처: boi 2009 

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]