记录
代码
#include <iostream>
#include <queue>
#include <functional>
using namespace std ;
priority_queue<int , vector<int> , greater<int> > fru ;
int main()
{
int n , tot = 0 ;
cin >> n ;
for (int i = 1 ; i = n ; i ++)
{
int temp ;
cin >> temp ;
fru.push(temp) ;
}
for (int i = 1 ; i = n - 1 ; i ++)
{
int cnt = 0 ;
cnt += fru.top() ;
fru.pop() ;
cnt += fru.top() ;
fru.pop() ;
fru.push(cnt) ;
tot += cnt ;
}
cout << tot << endl;
return 0 ;
}