~cpp
//TheTrip 10137
#include <iostream>
using namespace std;
#include <math.h>

double rounding(double num)
{
	
	return num;
}
int main()
{
	int n;
	int i;
	double *cost, sum, gap, avg;
	while(cin >> n)
	{	
		if(n == 0)
			break;
		cost = new double[n];
		
		sum = 0.0;
		gap = 0.0;
		avg = 0.0;
		for(i = 0; i < n; i++)
			cin >> cost[i];
		
		for(i = 0; i < n; i++)
		{
			sum += cost[i];
		}
		//평균 구하기
		avg = sum/(double)n;
		avg = ceil(avg);
		for(i = 0; i < n; i++)
		{	
			if(avg > cost[i])
				gap = gap + (avg - cost[i]);
			else
				gap = gap + (cost[i] - avg);
		}
		
		cout << "$" << (double)gap/2.00 << endl;
	}
	
	
	return 0;
}
- 미완성
Retrieved from http://wiki.zeropage.org/wiki.php/TheTrip/허아영
last modified 2021-02-07 05:28:13