# 문제점
– 입력값의 반올림 주의 : Cent 이하 단위를 무시할 것.
– 나머지 돈의 균등분배.
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <functional>
using namespace std;
int main()
{
int size;
int humens[1005];
int humens_spent[1005];
cin >> size;
while (size)
{
int sum = 0;
int avg;
for (int i=0; i<size; i++)
{
double temp;
cin >> temp;
humens[i] = (int)(temp * 100 + 0.5);
sum += humens[i];
}
sort(&humens[0], &humens[size], greater<int>() );
avg = sum/size;
int remain = sum% size;
sum = 0;
for (int i=0; i<size; i++)
{
humens_spent[i] = avg;
}
for (int i=0; i<remain; i++)
{
humens_spent[i]++;
}
for (int i=0; i<size; i++)
{
sum += abs(humens_spent[i] – humens[i]);
}
cout<< “$”<< fixed << setprecision(2) << (sum/2)/100.0 << endl;
cin >> size;
}
return 0;
}