Railway
The railway line between Zurich and Lugano spans a distance of kilometers, with a series of tunnels along the route. The journey is particularly scenic, as it crosses the beautiful and majestic Alps. Due to the nature of the railway, there are tunnels on the route, each defined by a starting point and an ending point. The i-th tunnel spans a distance between kilometers and kilometers from Zurich.
The railway is a single track, and each train is considered a point moving along this track. There are trains departing from Zurich and trains departing from Lugaro. Each train travels at a constant speed of sufficiently 1 kilometer per minute, regardless of the direction. The trains are expected to reach their destination in a time of minutes.
The task is to determine if a collision will occur within the tunnels. A collision occurs if two trains meet within a tunnel, as they cannot pass each other.
The input consists of the following: - The first line contains four integers: , , , and representing the length of the railway, the number of tunnels, the number of trains departing from Zurich, and the number of trains departing from Lugaro, respectively. - The second line contains t' integers representing the ending positions of the tunnels. - The fourth line contains n' integers representing the departure times of the trains from Lugaro.
The task is to determine if a collision will occur and print "YES" if a collision occurs and "NO" otherwise.
In the example, there are two tunnels on a 100-kilometer track. The only train departing from Zurich manages to avoid all trains to Lugaro. In the second example, two trains collide in the middle of the tunnel, resulting in a crash. In the third example, two trains meet at the end of the tunnel, which is a safe meeting.
The scoring section provides additional information about the constraints and the points available for each block.