题目1172:哈夫曼树

题目1172:哈夫曼树_第1张图片
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
//1172
priority_queue,greater > q;
int main(){
    int n;
   // freopen("input.txt","r",stdin);
    while(scanf("%d",&n)!=EOF){
        while(!q.empty())   q.pop();
        for(int i=0;i1){
            int a=q.top();q.pop();
            int b=q.top();q.pop();
            ans+=a+b;
            q.push(a+b);
        }
        cout<

你可能感兴趣的:(九度OJ)