标签:mod tracking while return printf amp content gre article
#include<iostream> #include<queue> using namespace std; #define read(x) scanf("%lld",&x) int main() { priority_queue<long long,vector<long long>,greater<long long> >q; long long n,temp,sum; read(n); if(n==1) { read(temp); printf("%lld\n",temp); return 0; } while(n--) { read(temp); q.push(temp); } sum=0; while(q.size()>1) { temp=q.top(); q.pop(); temp+=q.top(); q.pop(); sum+=temp; q.push(temp); } printf("%lld\n",sum); }小顶堆实现哈夫曼树
标签:mod tracking while return printf amp content gre article
原文地址:http://www.cnblogs.com/wzzkaifa/p/7135878.html