Skip to content

Commit

Permalink
Add 05919.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Feb 18, 2024
1 parent d0a61b4 commit 9dadcc4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions 05xxx/05919.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <iostream>
#include <cmath>
#include <numeric>
#include <vector>
using namespace std;

void solve(void) {
int n; cin >> n;
vector<int> v(n);
for (int i=0; i<n; i++) cin >> v[i];

int ans = 0;
int avg = accumulate(v.begin(), v.end(), 0) / n;
for (int i=0; i<n; i++) ans += abs(v[i] - avg);
cout << ans / 2;
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);

solve();
return 0;
}

0 comments on commit 9dadcc4

Please sign in to comment.