题解 | #小鸡啄米#
小鸡啄米
https://www.nowcoder.com/practice/c2a7f39bd97547eb9a1263d624af4cb3
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> arr(n); for(int i = 0; i < n; i++) cin >> arr[i]; sort(arr.begin(),arr.end(),greater<int>()); long long sum(0),cur(0); for(auto val : arr){ cur += val; sum += cur; } cout << sum << endl; return 0; }