#P9807. [POI 2022/2023 R1] wyp

[POI 2022/2023 R1] wyp

Background

This problem is translated from POI2022~2023R1 wyp

Problem Description

You are driving your newly bought car on a highway. The highway has 22 lanes (left and right). Initially, all vehicles are in the right lane. There are nn cars in front of you, but they are too slow, so you want to overtake them.

Your speed is VV, and the speed of the ii-th other car is viv_i (it is guaranteed that V>viV > v_i). If the front of your car is about to crash into another car, you will steer left to overtake. If, at your current position, there is a gap on the right lane that allows your car to move into it, then you will definitely move to the right.

Note that collisions between other cars may happen. After a collision, the speed of the car behind will change to be the same as the speed of the car in front of it.

Determine how many times your car will make a left-turn operation.

Input Format

The first line contains four integers nn, DD, WW, MM (1n1051 \leq n \leq 10^5, 1D1091 \leq D \leq 10^9, 1W,M10001 \leq W,M \leq 1000), representing the number of trucks, the length of your car, your car’s speed W/MW/M, and it is assumed that the coordinate of the front of your car is 00.

The next nn lines each contain four integers xix_i, did_i, wiw_i, mim_i (1xi,di1091 \leq x_i,d_i \leq 10^9, 1wi,mi10001 \leq w_i,m_i \leq 1000), representing the position, length, and speed wi/miw_i / m_i of the other cars.

It is guaranteed that the input is given in increasing order of xix_i.

Output Format

Output the number of left turns needed to overtake nn cars.

3 1 1 1
3 2 1 4
6 3 1 2
10 2 1 4
2

Hint

Explanation of the sample:

The subtasks are as follows:

Subtask ID Special Property Score
11 vi=vi+1v_i = v_{i+1} 1010
22 vivi+1v_i \leq v_{i+1} 2020
33 n1000n \leq 1000 3535
44 No additional constraints

In this problem, subtask 00 is the sample.

Translated by ChatGPT 5