Imagine a narrow road that can accommodate vehicles moving in only a single lane, such that overtaking is not possible. The road can be described by an array traffic in which each element corresponds to a vehicle. The absolute value of each entry represents the weight of the vehicle, while the sign specifies the vehicle's direction of movement: a positive value indicates travel toward the east end of the road, whereas a negative value indicates travel toward the west end. All vehicles move forward at the same constant speed and begin at the same time.
As the vehicles progress along the lane, it is possible for those moving eastward and those moving westward to encounter one another head-on. In these encounters, the heavier vehicle is the one that continues on its path, while the lighter vehicle is forced off the road and does not proceed any further. If two vehicles of equal weight attempt to cross the same stretch of road from opposite directions, both vehicles are removed from the lane entirely. Vehicles that move in the same direction never impede one another and thus proceed without any interference.
The task is to simulate this process and report the final arrangement of vehicles remaining on the road after all such eliminations are complete. The answer should reflect the surviving vehicles in their relative order along the lane once the system has reached a state where no further eliminations are possible.
Hard