排序不等式
一.排队打水
题目来源:排队打水
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100010;
typedef long long LL;
int n;
int a[N];
int main()
{
cin >> n;
for(int i = 1; i <=n; i ++) cin >> a[i];
sort(a+1, a + n+1);
LL res = 0, i;
for(int i = 1; i <= n; i ++)
{
res+=(n-i)*a[i];
}
cout << res;
return 0;
}