博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj3253
阅读量:4356 次
发布时间:2019-06-07

本文共 519 字,大约阅读时间需要 1 分钟。

#include
#include
using namespace std;#define read(x) scanf("%lld",&x)int main(){ priority_queue
,greater
>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);}
小顶堆实现哈夫曼树

转载于:https://www.cnblogs.com/wzzkaifa/p/7135878.html

你可能感兴趣的文章
图的遍历 | 1013 连通块块数
查看>>
Kinect 开发 —— 进阶指引(上)
查看>>
python学习笔记(六)time、datetime、hashlib模块
查看>>
uva489(需要考虑周全)
查看>>
C-关键字(二)
查看>>
排序笔记
查看>>
下载360doc.com里的文章
查看>>
【转】globk和glorg中使用的apr文件
查看>>
导航,头部,CSS基础
查看>>
PostMessage 解析
查看>>
Java语法基础(一)
查看>>
as3 sort
查看>>
hdu 2680 Choose the best route Dijkstra 虚拟点
查看>>
26. Remove Duplicates from Sorted Array java solutions
查看>>
[bzoj1185] [HNOI2007]最小矩形覆盖
查看>>
全景图制作详解
查看>>
React之todo-list
查看>>
cocoapods降级版本
查看>>
Leetcode:Unique Binary Search Trees
查看>>
Flash动画播放
查看>>