A21430.瑞瑞的木板 题解
2025-04-20 09:56:50
发布于:北京
5阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
priority_queue<long long, vector<long long>, greater<long long> > a;
int main(){
long long ans = 0, n, t;
cin >> n;
for(int i = 1; i <= n; i ++){
cin >> t;
a.push(t);
}
for(int i = 1; i <= n - 1; i ++){
int c, d;
c = a.top();
a.pop();
d = a.top();
a.pop();
ans += c + d;
a.push(c + d);
}
cout << ans;
return 0;
}
这里空空如也
有帮助,赞一个