提交时间:2023-08-23 10:50:45
运行 ID: 99578
#include <bits/stdc++.h> using namespace std; priority_queue<int,vector<int>,greater<int> >q; int n,x,ans=0; signed main() { cin >> n; for(int i = 1; i <= n; i++) { cin >> x; q.push(x); } ans = -q.top(); for(int i = n; i >= 1; i--) { //cout << q.top() << endl; ans += q.top()*(i); q.pop(); } cout << ans << endl; return 0; }