| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
果然 改成隆隆就a了~~~~~
#include<iostream>
#include<queue>
#include<algorithm>
#define ll long long
using namespace std;
priority_queue<ll,vector<ll>,greater<ll>> q;
int main()
{
ll N;
cin>>N;
ll number;
for(ll i=0;i<N;i++)
{
cin>>number;
q.push(number);
}
ll add=0;
if(N>1)
{
while(1)
{
ll compare=q.top();
q.pop();
compare+=q.top();
q.pop();
add+=compare;
if(!q.empty()) q.push(compare);
else break;
}
}
else
{
add=q.top();
}
cout<<add<<endl;
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator