Poj 3253 贪心水题
来源:互联网 发布:java实验指导书答案 编辑:程序博客网 时间:2024/04/24 10:29
Poj 3253
题目:http://poj.org/problem?id=3253
题目分析:
题目大意:用一块足够大的木板,分割成一块块的木材做成栅栏,但是得收费,每割x长的木板花x块钱。但是这题的代码做法相反。收费的长度可以等于两个两个拼起来。
代码:
#include <iostream>#include <queue>#include <functional>using namespace std;priority_queue<int, vector<int>, greater<int> > q;int main(){ int n; while(cin >> n && n) { while(n--) { int tmp; cin >> tmp; q.push(tmp); } long long res = 0; while(q.size() > 1) { int min1 = q.top(); q.pop(); int min2 = q.top(); q.pop(); int sum = min1 + min2; res += sum; q.push(sum); } cout << res << endl; } return 0;}
0 0
- Poj 3253 贪心水题
- poj 2590 水题贪心
- poj 3253 (贪心)
- poj 3253 huffman 贪心
- poj Yogurt factory (贪心水题)
- POJ 2586 水贪心。
- poj 贪心题
- POJ 3253 Fence Reair (贪心)
- POJ 3253 Fence Repair(贪心)
- poj 3253 Fence Repair 贪心
- POJ 3253 Fence Repair 贪心
- Poj 3253 Fence Repair【贪心】
- POJ 3253 贪心 优先队列
- POJ 3253 Fence Repair(贪心)
- POJ 3627 Bookshelf 贪心 水~
- poj+数模组要做的水题+Stripies 贪心
- POJ 3253 Fence Repair (贪心&优先队列)
- poj 3253(贪心,记得long long)
- 九九乘法表
- mrc项目转arc注意点
- 3月8号随记
- Linux显示用户注册名
- Python3.4中filter函数,map函数和reduce函数
- Poj 3253 贪心水题
- leetCode #6 ZigZag Conversion
- KNN算法及R语言实现
- Linux内核分析 第一次作业
- 不借助第三个量,交换两个量的值
- js事件的监听器的使用
- Object类中的toString和equal方法
- 选机房(贪心模拟)
- 基于SVN + Maven的构建发布Demo之二——解决回滚问题