Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:果然 改成隆隆就a了~~~~~

Posted by 877801131 at 2016-12-15 19:12:05 on Problem 3253
In Reply To:果然 改成隆隆就a了~~~~~ Posted by:268123lry at 2014-12-31 21:49:37
> 
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator