10分求助
查看原帖
10分求助
1020531
liuyiyang_khaili楼主2024/1/22 10:21
#include<bits/stdc++.h>
using namespace std;
const int N = 10007;
int n;
int a[N];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	long long now = a[1], ans = 0;
	for (int i = 2; i <= n; i++) {
		ans += now + a[i];
		now += a[i];
	}
	cout << ans;
	return 0;
}
2024/1/22 10:21
加载中...