题目:http://poj.org/problem?id=3253
没用long long wrong 了一次
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<stack>
#include<queue>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std; int main()
{
long long n,i,j,a,sum,cnt;//或者 __int64 n,i,j,a,sum,cnt;
priority_queue<int,vector<int>,greater<int> >pq;
cin>>n;
for(i=; i<n; i++)
{
cin>>a;
pq.push(a);
}
sum=;
while(!pq.empty())
{
cnt=pq.top();
pq.pop();
if(pq.empty())
break;
cnt+=pq.top();
sum+=cnt;
pq.pop();
pq.push(cnt);
}
cout<<sum<<endl;
return ;
}