WeiSheMeBuKanWoDe

zhangjinghao 2023-11-18 16:01:00 2023-11-18 16:15:14 4 返回题目

... #include<bits/stdc++.h> using namespace std; priority_queue w; int main(){ int n,s,z=0; cin>>n; for(int i=1;i<=n;i++){ cin>>s; w.push(-s); } while(w.size()>=2){ int a= -w.top(); w.pop(); int b= -w.top(); w.pop(); z+=(a+b); w.push(-(a+b)); } cout<<z; return 0; } ...

{{ vote && vote.total.up }}