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先拿.每次可以从一堆 ...
随机推荐
- kubernetes实战(二十五):kubeadm 安装 高可用 k8s v1.13.x
1.系统环境 使用kubeadm安装高可用k8s v.13.x较为简单,相比以往的版本省去了很多步骤. kubeadm安装高可用k8s v.11 和 v1.12 点我 主机信息 主机名 IP地址 说明 ...
- Html各组件MIME类型
扩展名 类型/子类型 * application/octet-stream 323 text/h323 acx application/internet-property-stream ai appl ...
- SQL SERVER与ORACLE的几点区别
1.数据类型不同. sql server 的数据类型 int ,smallint ,char,varchar,nchar,nvarchar,ntext,datetime,smalldatet ...
- 集成百度地图API实现定位
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/u010982006/article/details/32347107 一.百度地图API获取定位 A ...
- Windows五种IO模型性能分析和Linux五种IO模型性能分析
Windows五种IO模型性能分析和Linux五种IO模型性能分析 http://blog.csdn.net/jay900323/article/details/18141217 http://blo ...
- 详解Linux(centos7)下安装OpenSSL安装图文方法
OpenSSL是一个开源的ssl技术,由于我需要使用php相关功能,需要获取https的文件所以必须安装这个东西了,下面我整理了两种关于OpenSSL安装配置方法. 安装环境: 操作系统:CentO ...
- pycharm Unresolved reference 无法引入包
1. 问题描述: 在项目中P存在文件夹A.B.C,A有文件夹a和b,在a中引入b的一个类, a.py: from b import func1 虽然运行成功,但是在Pycharm中显示: Unreso ...
- JS中的对象数组
<html> <head> <title>对象数组的字符串表示</title> <script type="text/javascrip ...
- UVALive - 7269 I - Snake Carpet
思路: 多画画就发现从五的时候可以这么填: 六的时候这么填: 七的时候这么填: 看出规律了吗? 没看出的话再画画把. #include <bits/stdc++.h> using name ...
- uva1330 在一个大的矩阵中寻找面积最大的子矩阵
大白书 P50页 #include <algorithm> #include <cstdio> using namespace std; ; int ma[maxn][maxn ...