|洛谷|堆|P1334 瑞瑞的木板
来源:互联网 发布:淘宝企业开店怎么开 编辑:程序博客网 时间:2024/04/27 20:04
https://www.luogu.org/problem/show?pid=1334
类似合并果子,注意要用long long
#include<cstdio>#include<algorithm>#include<cstring>#include<queue>#define ms(i,j) memset(i,j, sizeof i);using namespace std;int n;priority_queue<long long, vector<long long>, greater<long long> > p;int main(){scanf("%d",&n);for (int i=1;i<=n;i++) {int x;scanf("%d", &x);p.push(x);}long long tot = 0;while (p.size()!=1){long long a = p.top(); p.pop();long long b = p.top(); p.pop();tot += a+b;p.push(a+b);}printf("%lld\n", tot); return 0;}
0 0
- |洛谷|堆|P1334 瑞瑞的木板
- 堆——洛谷 P1334 瑞瑞的木板
- 【u009】瑞瑞的木板
- 洛谷 2664_切割木板_堆
- 木板
- 一道有趣的木板问题
- [二维01背包]VIJOS P1334 NASA的食物计划
- BZOJ 1724 [Usaco2006 Nov]Fence Repair 切割木板 贪心+堆
- BZOJ 1724: [Usaco2006 Nov]Fence Repair 切割木板 堆
- 贪心 000 关于运送木板的问题
- 洛谷 Divided the woods(木板分隔)
- Vijos P1334 NASA的食物计划(动态规划,二维费用的01背包)
- 给定整型数组,其中每个元素表示木板的高度,木板的宽度都相同,求这些木板拼出的最大矩形的面积。并分析时间复杂度。
- TYVJ P1334 powermax
- vijos-p1334 2008.11.9
- 2013 Changsha Regional 一样的木板一样的气球
- 教育是中国发展的最短一块木板(转贴)
- 分形图形:千伏高压下的湿木板
- Unity给按钮设置图标
- jdk源码查看
- iOS 代理反向传值
- bzoj 3209 花神的数论题
- Phabricator代码审查使用方法(mac版)
- |洛谷|堆|P1334 瑞瑞的木板
- iOS 获取蜂窝信号强度
- Win10如何搭建FTP服务器
- win7安装vs2015出错安装包损坏或丢失 windows6.1-kb2999226-x64.msu
- Mesos Nvidia GPU Support 翻译
- nginx静态资源服务器简单配置
- View工作原理(measure、layout、draw)
- Linux Namespaces机制
- (Unity3d)Vuforia开发基础三-模型替换