文章
61
粉丝
137
获赞
18
访问
38.3k
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
priority_queue<int, vector<int>, greater<int>> pq;
cin >> n;
for(int i = 0; i < n; i++){
int tmp;
cin >> tmp;
pq.push(tmp);
}
int ans = 0;
while(pq.size() != 1){
int tmp = 0;
tmp += pq.top();
pq.pop();
tmp += pq.top();
pq.pop();
pq.push(tmp);
ans += tmp;
}
cout << ans << endl;
return 0;
}
登录后发布评论
暂无评论,来抢沙发