模拟
- 类似 AcWing 1208. 翻硬币 。
#include <iostream>
using namespace std;
const int N = 110;
int a[N];
int main() {
int n, total = 0, ans = 0;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i], total += a[i];
int avg = total / n;
for (int i = 1; i <= n; i++)
if (a[i] != avg) a[i + 1] += a[i] - avg, ans++;
cout << ans << endl;
return 0;
}