The Live Forecast
You’re monitoring a live sensor dashboard. Readings arrive one by one, and you need to make a quick forecast before each new reading appears.
Your rule is simple: predict the next value using the average of all values seen so far.

The first line of the input contains a single integer n
- the size of the initial historical (training) set. The second line contains n
space-separated floating-point numbers.
The third line contains a single integer m
- the number of incoming live readings. Each of the next m
lines contains one number - the true reading that arrives at that moment.
For each of the m
moments, print the current mean of all values seen so far (the n
training values plus any previous live readings) each on a separate line.
Input | Output |
---|---|
3 | 20 |
1 | 100 |
2 | 2 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB