poj3253
来源:互联网 发布:网络零售的优势和缺点 编辑:程序博客网 时间:2024/05/16 16:15
#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);}小顶堆实现哈夫曼树
0 0
- poj3253
- POJ3253
- poj3253
- poj3253
- poj3253
- poj3253
- POJ3253
- poj3253
- POJ3253
- poj3253
- poj3253
- POJ3253
- poj3253
- poj3253
- poj3253
- poj3253
- poj3253
- poj3253
- 大数据是新的富矿 数据分析成为掘金关键
- 阿里云win2008服务器使用---测试过
- LeetCode-Interleaving String
- Zabbix中禁用guest用户
- SIFT算法:Matlab程序代码测试例子的说明(Lowe的代码)
- poj3253
- 影响网站加载速度之外部资源文件分析
- Question 5
- Timesten cache group aging 功能的实现
- UVA (POJ 2109) Power of Cryptography
- opensips创建数据库时报database engine not specified错误的解决
- Hi, Eclipse
- JDBC驱动程序
- POJ1423