51NOD 1117 聪明的木匠
来源:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1117
挑战原题吧 大概
每次挑选最小的两个,合起来
#include <bits/stdc++.h>
using namespace std; int main ()
{
int n;
scanf("%d",&n);
priority_queue<int,vector<int>,greater<int> > Q;
for(int i=;i<n;i++){
int x;scanf("%d",&x);
Q.push(x);
}
long long sum = ;
while (Q.size()> ){
int t1 = Q.top();Q.pop();
int t2 = Q.top();Q.pop();
sum += t1+t2;
Q.push(t1+t2);
}
printf("%lld",sum);
}
51NOD 1117 聪明的木匠的更多相关文章
- 51nod 1117 聪明的木匠 (贪心)
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1117 跟挑战程序书上例题一样,将要切割的n断木板,分别对应二叉树树的叶子 ...
- 51nod 1117 聪明的木匠 (哈夫曼树)
题目:传送门. 题意:中文题. 题解:就是构造一颗哈夫曼树,数据结构里的知识. #include <iostream> #include <cstdio> #include & ...
- POJ 3253 Fence Repair C++ STL multiset 可解 (同51nod 1117 聪明的木匠)
Fence Repair Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 53106 Accepted: 17508 De ...
- 51nod 1117 贪心
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1117 1117 聪明的木匠 题目来源: 河北大学算法艺术协会 基准时间限 ...
- 51nod1117 聪明的木匠【贪心+优先队列】
一位老木匠需要将一根长的木棒切成N段.每段的长度分别为L1,L2,......,LN(1 <= L1,L2,-,LN <= 1000,且均为整数)个长度单位.我们认为切割时仅在整数点处切且 ...
- 51Nod--1117 聪明的木匠(排序)
我们可以反过来想,如何将这几个线段组成一根 并且每次花费是组成的两段的和 #include<bits/stdc++.h> using namespace std; #define maxn ...
- 51nod水题记
妈呀51nod已经刷不动了又开始跟bzoj一样总是得看题解了...那么发一下总结吧... 1051:最大子矩阵 #include<cstdio> #include<cstring&g ...
- 51Nod 1069 Nim游戏 (位运算)
题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1069 有N堆石子.A B两个人轮流拿,A先拿.每次只能从一堆 ...
- 51Nod 1072 威佐夫游戏
题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1072 有2堆石子.A B两个人轮流拿,A先拿.每次可以从一堆 ...
随机推荐
- 【HTML5】初识HTML5
HTML5 简介 HTML5是HTML最新的修订版本,2014年10月由万维网联盟(W3C)完成标准制定. HTML5的设计目的是为了在移动设备上支持多媒体. HTML5 简单易学. HTML5 是下 ...
- li设置float后ul无法包裹li问题解决
解决办法:灰常简单,只需给ul添加样式 ul{ overflow: auto; } 即可
- java获取屏幕密度
方法1: float xdpi = getResources().getDisplayMetrics().widthPixels;float ydpi = getResources().getDisp ...
- HandlerSocket
HandlerSocket http://www.uml.org.cn/sjjm/201211093.asp 目录: HandlerSocket的原理 HandlerSocket的优势和缺陷阐述 Ha ...
- 为什么GPU可以用于科学计算【转载】
转自:https://blog.csdn.net/xihuanyuye/article/details/81178352 https://www.zhihu.com/question/35063258 ...
- PAT 1066 Root of AVL Tree[AVL树][难]
1066 Root of AVL Tree (25)(25 分) An AVL tree is a self-balancing binary search tree. In an AVL tree, ...
- ubuntu开发环境下eclipse的alt+/自动补全功能不能用
解决方法:windows ---preferences---General---keys ,把在搜索框中搜Word Completion,把该快捷键unbind,然后给content assist 绑 ...
- 使用免费的Let's Encrypt通配符证书 升级我们的网站
Let's Encrypt通配符证书的官方启用日期:2018年3月13日 也就是说,2018年3月13日之后,我们就可以使用Let's Encrypt通配符证书了,当然是免费的. Let's Encr ...
- [LeetCode] 711. Number of Distinct Islands II_hard tag: DFS
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) conn ...
- Selenium Webdriver——操作隐藏的元素(三)switchTo().frame()
在web 应用中经常会遇到frame 嵌套页面的应用,页WebDriver 每次只能在一个页面上识别元素,对于frame 嵌套内的页面上的元素,直接定位是定位是定位不到的.这个时候就需要通过switc ...