Solution for DMOPC '14 Contest 1 P3 - New Students in C++


May 2, 2020 0.094792 seconds C++
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n, s;
	cin >> n;
	int t;
	double avg = 0;
	int c = 0;
	
	for(int i = 0; i < n; i++){
		cin >> t;
		avg += t;
	}
	
	cin >> s;
	c = n;
	for(int i = 0; i < s; i++){
		cin >> t;
		c++;
		avg += t; 
		cout << setprecision(5) << (avg / c);
		if( fmod(avg / c, 1) == 0){
			cout << ".000";
		}
		cout << "\n";
		
	}

	
	return 0;
}

Editorial


No editorial for this problem. :(

Original Problem


You can view the original page for this problem on the DMOJ.