POJ 3253 Fence Repair
来源:互联网 发布:业界良心知乎 编辑:程序博客网 时间:2024/05/17 03:29
贪心水题,用优先队列水过
#include <iostream>#include <cstdio>#include <cstring>#include <queue>using namespace std;long long ans,tll;priority_queue<long long, vector<long long>, greater<long long> > q;int main(){ int n,i,j,t; while (!q.empty()) q.pop(); scanf("%d",&n); for (i=0; i<n; i++) { scanf("%d",&t); q.push(t); } ans=0; while (q.size() >= 2) { tll=q.top(); q.pop(); tll+=q.top(); ans+=tll; q.pop(); q.push(tll); } printf("%lld\n",ans); q.pop(); return 0;}
- POJ 3253 Fence Repair
- poj 3253 Fence Repair
- POJ 3253 Fence Repair
- POJ 3253 Fence Repair
- POJ 3253 Fence Repair
- POJ 3253 Fence Repair
- poj 3253 Fence Repair
- POJ 3253Fence Repair
- POJ--3253 -- Fence Repair
- poj-3253-Fence Repair
- POJ 3253 Fence Repair
- POJ 3253 Fence Repair
- poj 3253 Fence Repair
- poj 3253 Fence Repair
- POJ - 3253 Fence Repair
- POJ 3253 Fence Repair
- poj 3253 Fence Repair
- poj 3253---Fence Repair
- hdu 4463 Outlets
- sql练习题
- Window CE 6.0流驱动开发动态加载实验
- [seasar][填鸭指南](一)基础知识:结构和跳转
- 人与自然关系的思考
- POJ 3253 Fence Repair
- 时间管理
- 用IO对二进制文件进行复制(面试常考)
- VB.Net实现将文本文件中的数据自动插入数据库的小工具
- poj2516解题报告
- Ibatis小结
- Visual Studio 2012和.NET Framework 4.5
- 取消MyEclipse自动更新
- Struts2+JSON 实现AJAX 返回对象和列表