// UVa 591 - Box of Bricks
#include <iostream>
using namespace std;
int main() {
int n, a[50];
int set_number = 0;
cin >> n;
while (n) {
set_number++;
int avg = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
avg += a[i];
}
avg /= n;
int sol = 0;
for (int i = 0; i < n; i++)
if (avg > a[i])
sol += avg - a[i];
else
sol += a[i] - avg;
cout << "Set #" << set_number << endl;
cout << "The minimum number of moves is " << sol / 2 << "." << endl;
cout << endl;
cin >> n;
}
}
No comments:
Post a Comment