提交时间:2026-07-20 21:22:58
运行 ID: 214531
#include <iostream> using namespace std; int main() { int n; cin >> n; int a[105]; int sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } int avg = sum / n; int moves = 0; int carry = 0; // 从左往右累积的差值 for (int i = 0; i < n; i++) { carry += a[i] - avg; if (carry != 0) { moves++; } } cout << moves << endl; return 0; }