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