文章
12
粉丝
10
获赞
1
访问
6.1k
#include<iostream>
#include<queue>
using namespace std;
priority_queue<int,vector<int>,greater<int>> Q;
int n,t;
int main()
{
int Sum = 0;
cin>>n;
while(n--)
cin>>t,Q.push(t);
while(Q.size()>1)
{
int m1 = Q.top();
Q.pop();
int m2 = Q.top();
Q.pop();
Sum = Sum+m1+m2;
Q.push(m1+m2);
}
cout<<Sum;
return 0;
}
登录后发布评论
暂无评论,来抢沙发