Self-driving Car Sensor Blend
A self-driving car estimates the distance to the car ahead using two sources: a fast, reactive sensor (e.g., radar) and a slower but steadier signal (e.g., lidar/maps fused over time). To stabilize the distance, the car blends these two readings with a weight.

The first line of the input contains a single integer n
- the number of reading pairs.
The second line contains a decimal w
(0 ≤ w ≤ 1) - how much to trust the fast reading.
The next n
lines each contain two numbers a b
:
a
: the fast reading (radar-like),b
: the slow reading (lidar/map-like).
For each pair, print the stabilized distance:
Input | Output |
---|---|
3 | 13 |
3 | 9.6 |
2 | 3 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB