@[小渣青999](/user/170047)
为什么要那么写?这么写多简单
```cpp
#include <bits/stdc++.h>
using namespace std;
priority_queue <int,vector<int>,greater<int> > q;
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int x;
scanf("%d",&x);
q.push(x);
}
int ans=0;
while(q.size()>1)
{
int t1=q.top();q.pop();
int t2=q.top();q.pop();
q.push(t1+t2);
ans+=t1+t2;
}
printf("%d\n",ans);
return 0;
}
```
by Smile_Cindy @ 2020-02-07 21:33:39
@[Alpha](/user/87058)
不太会优先队列TAT 就没想着用
by 小渣青999 @ 2020-02-07 21:46:08
@[Alpha](/user/87058)
我去康康 多谢多谢
by 小渣青999 @ 2020-02-07 21:46:54