题目描述
blablabla
样例
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e6;
int main()
{
int n;
cin >> n;
priority_queue<LL, vector<LL>,greater<LL>>heap;
for(int i = 1; i <= n; i ++ ){
int t;
cin >> t;
heap.push(t);
}
if(n % 2 == 0) heap.push(0);
LL res = 0;
while(heap.size() > 1){
LL sum = 0;
for(int i = 1; i <= 3; i ++ ){
sum += heap.top();
heap.pop();
}
res+=sum;
heap.push(sum);
}
cout << res;
}
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla