Space Probe
Time limit2sMemory limit512 MB
Given a random start time in [t1,t2] and fixed measurement offsets, find the probability that no measurement lands inside any forbidden interval.
- Level
Medium7 of 10
- Topics
- Intervals, Math, Sorting, Implementation
- Solved
- No attempts yet
Problem
A space probe is out of control. It starts its measurement sequence at some time , measured in seconds, that lies between and , and nobody knows exactly when. Every start time in the interval is equally likely.
The measurement sequence is preprogrammed and cannot be changed. It consists of successive measurements whose offsets are fixed. If the sequence starts at time , the first measurement happens at time , the second at time , and the last one at time . A measurement is instantaneous, so its duration is seconds.
The probe rotates in space and cannot be steered. Because of the rotation there are stretches of time during which the measuring devices point at the Sun. A measurement taken while a device points at the Sun destroys its sensors and the whole probe is lost. The trajectory and the rotation are known, so the time intervals during which no measurement may be taken are known as well.
Compute the probability that every measurement succeeds and the probe is not lost to solar radiation.
All given times and interval lengths are integers. Only the start time of the sequence is unknown, and it may be any real number in .
Input
The first line contains four integers , , , . Here is the number of measurements, is the number of time intervals in which no measurement may be taken, and and bound the window in which the measurement sequence can begin.
The second line contains integers , the offsets at which the measurements happen after the sequence begins. The sequence is strictly increasing.
Each of the following lines contains two integers and that describe one forbidden interval . It is guaranteed that and that the intervals do not overlap, that is, for every .
- all values and are non-negative and smaller than
Values on one line are separated by single spaces.
Output
Print the probability that the probe survives, that is, the probability that no measurement falls inside any forbidden interval.
Every input value is an integer, so this probability is a rational number. Print it as an irreducible fraction in the form p/q, with no space around the slash, where and . Print a probability of as 0/1 and a probability of as 1/1.