stlyyds
#include<bits/stdc++.h>
using namespace std;
int n, t, a, b;
long long res;
priority_queue<int, vector<int>, greater<int>> h;
int main()
{
cin >> n;
while(n --) cin >> t, h.push(t);
while(h.size() - 1)
{
a = h.top(), h.pop();
b = h.top(), h.pop();
res += (long long)a + (long long)b;
h.push(a + b);
}
cout << res;
}
兄弟有时间填个邀请码hhhhhhhhh(可以得AC币,邀请码在学生认证那填) 我的邀请码是:GUDFH