Algo-Trian

This commit is contained in:
e2hang
2025-09-21 12:21:50 +08:00
parent 24522486f1
commit 3bde00039c
25 changed files with 842 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> a(n);
int sum = 0;
for(int i = 0; i < n; i++){
cin >> a[i];
sum += a[i];
}
int avg = sum / n;
int js = 0;
for(int i = 0; i < n - 1; i++){
if(a[i] != avg){
int tmp = a[i] - avg;
a[i] = avg;
a[i + 1] += tmp;
js++;
}
}
cout << js << endl;
return 0;
}