2022.5.3 AcWing 每日一题

简单签到

#include <bits/stdc++.h>
using namespace std;

// 贪心

const int N = 1e4 + 10;

int n;
int sum;
int x;
int w[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
		sum += w[i];
	}

	x = sum / n;

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (w[i] > x) {
			ans += w[i] - x;
		}
	}

	printf("%d\n", ans);

	return 0;
}
posted @ 2022-05-03 20:10  superPG  阅读(13)  评论(0编辑  收藏  举报