poj 3253
来源:互联网 发布:网络共享服务器 反应慢 编辑:程序博客网 时间:2024/05/19 21:40
题目链接 http://poj.org/problem?id=3253
#include <queue>#include <stack>#include <math.h>#include <vector>#include <stdio.h>#include <iostream>#include <string.h>#include <algorithm>#include <functional>#define N 100#define mem(a) memset(a,0,sizeof(a));using namespace std;struct cmp1{ bool operator()(int &a,int &b) { return a > b;//最小值优先 }};int main(){ int n; long long ans=0,x,y,z; priority_queue<int,vector<int>,cmp1>Q; cin >> n; while(n--) { cin >> x; Q.push(x); } while(Q.size()>1) { y = Q.top(); Q.pop(); z = Q.top(); Q.pop(); Q.push(y+z); ans+=y+z; } cout << ans << endl; return 0;}
0 0
- POJ 3253
- poj 3253
- poj 3253
- poj 3253
- poj----3253
- poj.3253
- poj 3253
- POJ 3253
- poj 3253
- poj-3253
- POJ-3253
- POJ 3253
- poj 3253
- poj-3253
- poj-3253
- POJ 3253
- POJ 3253
- POJ 3253
- interrupt的使用
- 动态规划之矩阵链相乘问题(算法导论)
- C++在单继承、多继承、虚继承时,构造函数、复制构造函数、赋值操作符、析构函数的执行顺序和执行内容
- UNP 学习笔记
- 为什么 Thread.stop和Thread.suspend等被废弃了?
- poj 3253
- 关于yum和rpm
- 生成与中文字符串相对映的拼音首字母串的函数(js)
- MATLAB 视频读取时:Unable to locate decompressor to decompress video stream 错误原因
- 设计模式 之 中介者
- C++中如何使函数返回数组
- Linux 安装和测试 cblas, lapack, lapacke
- 数据库设计——三范式概念+实战
- VC MFC中修改STATIC的文本颜色和文本字体等