标签:extra lin repair mount eal ota enc clu nal
1 #include<cstdio> 2 #include<cstring> 3 #include<queue> 4 #include<vector> 5 #include<algorithm> 6 #define ll long long int 7 using namespace std; 8 int main() 9 { 10 int n,i; 11 int x,y; 12 int a; 13 ll ans=0; 14 priority_queue<int,vector<int>,greater<int> >q; 15 scanf("%d",&n); 16 for(i=0;i<n;i++) 17 { 18 scanf("%d",&a); 19 q.push(a); 20 } 21 while(q.size()>1) 22 { 23 x=q.top(); 24 q.pop(); 25 y=q.top(); 26 q.pop(); 27 ans+=x+y; 28 q.push(x+y); 29 } 30 printf("%lld\n",ans); 31 return 0; 32 }
标签:extra lin repair mount eal ota enc clu nal
原文地址:https://www.cnblogs.com/wkfvawl/p/9772325.html