delete pics to save space
This commit is contained in:
23
1.1090.cpp
Normal file
23
1.1090.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
// luogu-judger-enable-o2
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int n,x,res;
|
||||
priority_queue<int,vector<int>,greater<int>> Q;
|
||||
int main()
|
||||
{
|
||||
scanf("%d",&n);
|
||||
while(n-->0)
|
||||
{
|
||||
scanf("%d",&x);
|
||||
Q.push(x);
|
||||
}
|
||||
while(Q.size()>=2)
|
||||
{
|
||||
int a=Q.top(); Q.pop();
|
||||
a+=Q.top(); Q.pop();
|
||||
Q.push(a);
|
||||
res+=a;
|
||||
}
|
||||
printf("%d\n",res);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user