The Halfway Fix
Your lab has a temperature sensor that’s a bit noisy. To stabilize the readings, the lab uses a simple trick: it blends each new reading with the long-term average, pulling the value halfway toward that average.
Today, you’re asked to build a tiny predictor that follows this rule.

First, you’ll learn the sensor’s long-term behavior from past data. You should compute the global mean M
of the historical readings. Then, for each incoming reading r
, output the adjusted prediction:
The first line of the input contains a single integer n
- the number of past readings.
The second line contains n
space-separated integers representing the reading values of the sensor.
The third line contains a single integer q
- the number of incoming readings to adjust.
The fourth line contains q
numbers (integers or decimals) - the incoming readings.
The program should print one adjusted value per line, in order.
Input | Output |
---|---|
4 | 15.75 |
5 | 6 |
4 | 9.5 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB