HDU 1051: Wooden Sticks(贪心)】的更多相关文章

Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14126    Accepted Submission(s): 5842 Problem Description There is a pile of n wooden sticks. The length and weight of each stick a…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 22000    Accepted Submission(s): 8851 Problem Description There is a pile of n wooden sticks. The length and weight of each stick ar…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)        Total Submission(s): 23527    Accepted Submission(s): 9551 There is a pile of n wooden sticks. The length and weight of each stick are known in a…
本题一看就知道是最长不减序列了,一想就以为是使用dp攻克了. 只是那是个错误的思路. 我就动了半天没动出来.然后看了看别人是能够使用dp的,只是那个比較难证明其正确性,而其速度也不快.故此并非非常好的解决方法. 所以我就直接硬算.硬模拟选择出非减子序列,选完就出答案了. 思路: 1 依照长度排序 2 依照不减原则选择重量,选一个,消灭一个. 最后消灭完了,就处理完成,答案就自然出来了. 原来是一道披着dp的外套的模拟题啊!一道伪装成难题的简单题. 代码也能够写的非常简洁: #include <s…
#include <iostream>#include<stdio.h>#include<cmath>#include<algorithm>using namespace std;struct product{    int w;    int l;     bool operator<(product &p2)    {        if(w==p2.w)return l<=p2.l;        else return w<…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10423    Accepted Submission(s): 4287 Problem Description There is a pile of n wooden sticks. The length and weight of each stick ar…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 15564    Accepted Submission(s): 6405 Problem Description There is a pile of n wooden sticks. The length and weight of each stick a…
Wooden Sticks 点我挑战题目 题意分析 给出T组数据,每组数据有n对数,分别代表每个木棍的长度l和重量w.第一个木棍加工需要1min的准备准备时间,对于刚刚经加工过的木棍,如果接下来的木棍l和w均小于等于上一根木棍的l和w那么就不许要准备时间,否则的话还需要1min的准备时间.求解对于每组数据,所需要的最小的准备时间是多少. 贪心策略. 对木棍进行降序排序,首要关键字是l,次要关键字是w(可以颠倒).然后选取最顶端的木棍,向下遍历,对于当前木棍,若l和w均小于等于顶层木棍,那么标记它…
题目链接>>> 转载于:https://www.cnblogs.com/Action-/archive/2012/07/03/2574800.html  题目大意: 给n根木棍的长度和重量.根据要求求出制作木棍的最短时间.建立第一个木棍需要1分钟,若是接着要制作的木棍重量和长度都比此木棍长就不需要建立的时间,若是没有,则再需要建立时间.求时间最小为多少. 解题思路: 对木棍的长度和重量进行排序,以长度为首要考虑.排序完后的不一定都是下一根木棍重量和长度都大于前一根的.于是,我们对排序后的…
题意: 有 n 根木棒,长度和质量都已经知道,需要一个机器一根一根地处理这些木棒. 该机器在加工过程中需要一定的准备时间,是用于清洗机器,调整工具和模板的. 机器需要的准备时间如下: 1.第一根需要1min的准备时间: 2.在加工了一根长为 l ,重为 w 的木棒后,接着加工一根长为 l’(l <= l’),重为 w’ (w <= w’)的木棒是不需要任何准备时间的,否则需要1min时间. 求加工 n 根木棒所用的最少时间.例如现有长和重分别为(4,9),(5,2),(2,1),(3,5)和(…
题意:给出n个木头的重量wi,长度li,如果满足w[i+1]>=w[i]且l[i+1]>=l[i],则不用耗费另外的加工时间,问至少需要多长时间加工完这些木头. 第一次做这一题目也没有做出来---而且也是好久以前---于是又看题解了--- 发现和将木材按两个关键字(先按重量由大到小排,如果重量相等的话则按长度由大到小排)排序后,和导弹拦截系统是一样的了,求长度的最长上升子序列. 自己写的二分查找一直输不出结果----555555 后来用了题解里面的lower_bound函数 搜了一点lower…
点击打开链接 1270: Wooden Sticks [贪心] 时间限制: 1 Sec 内存限制: 128 MB 提交: 31 解决: 11 统计 题目描述 Lialosiu要制作木棍,给n根作为原料的木棍的长度和重量.根据要求求出制作木棍的最短时间. 首先我们知道制作第一个木棍需要1分钟,若是接着要制作的木棍的重量和长度都不少于当前的木棍,那么就不需要建立的时间,若是没有,则再需要建立时间,也就是1分钟. 举个例子,如果你有五个原料木棍,他们的长度和重量分别是(4,9), (5,2), (2,…
http://acm.hdu.edu.cn/showproblem.php?pid=1051 Problem Description There is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in one by one fashion. It needs s…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12443    Accepted Submission(s): 5167 Problem Description There is a pile of n wooden sticks. The length and weight of each stick ar…
题目连接:2322 Wooden Sticks 题目大意:给出要求切的n个小木棍 , 每个小木棍有长度和重量,因为当要切的长度和重量分别大于前面一个的长度和重量的时候可以不用调整大木棍直接切割, 否则要进行调整.现在要求求出一个序列, 使得调整的次数最少, 输出调整的次数. 解题思路:将n个小木棍先按照 长度和重量的大小排序,然后按照顺序将小木棍分堆,可入堆的要求是长度和重量大于当前这个堆的长度和重量,入堆之后, 要将新的木棍的属性赋值个这个堆, 如果当前所有堆都没法放下这个木棍, 就得单独放成…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 26095    Accepted Submission(s): 10554 Problem Description There is a pile of n wooden sticks. The length and weight of each stick a…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 27724    Accepted Submission(s): 11221 Problem Description There is a pile of n wooden sticks. The length and weight of each stick a…
Description There is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in one by one fashion. It needs some time, called setup time, for the machine to prepare…
Wooden Sticks. win the wooden spoon:成为末名. 题目地址:http://poj.org/problem?id=1065 There is a pile of n wooden sticks. a woodworking machine:木工机器. setup time:启动时间. my codes: #include<iostream> #include<cstdio> #include<cstring> #include<al…
题目 There is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in one by one fashion. It needs some time, called setup time, for the machine to prepare processi…
木棍 时间限制: 1000MS   内存限制: 10000K 提交总数: 27336   接受: 11857 描述 有一堆木棍.每根杆的长度和重量是预先已知的.这些木棍将由木工机器逐一加工.它需要一些时间,称为设置时间,以便机器准备处理棒.设置时间与清洁操作以及更换机器中的工具和形状相关联.木工机械的安装时间如下: (a)第一根木棒的安装时间为1分钟. (b)在加工长度为l且重量为w的棒之后,如果l <= 1'且w <= w',则机器将不需要设置长度l'和重量w'的设定时间.否则,需要1分钟进…
(- ̄▽ ̄)-* 这道题用到了cstdlib库的qsort()函数: 用法链接:http://www.cnblogs.com/syxchina/archive/2010/07/29/2197382.html #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> using namespace std; struct s…
题意是处理一批木棍,如果当前处理的木棍长度和重量均大于前一根木棍的长度和重量,则处理当前木棍花费为 0,否则花费为 1. 用结构体存储木棍信息,将木棍按照长度从小到大排序,若长度相等则按照重量从小到大排序,在序列中找到比当前所处理的木棍长度和重量均大于且未处理的木棍再进行处理,若没有满足要求的木棍了,则再次从头开始处理未处理过的木棍,直到所有的木棍处理完毕. 代码如下: #include <bits/stdc++.h> using namespace std; struct stick { i…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11244    Accepted Submission(s): 4627 Problem Description There is a pile of n wooden sticks. The length and weight of each stick a…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8899    Accepted Submission(s): 3630 [解题思路]初学贪心仅知道一些理论的知识,这题说是贪心自己也没啥感觉,做题的思路是在抛开贪心的概念然后按照自己的想法实现出来,实现之后想在思路中找到贪心的影子,只能看到每次都是找尽可能多的s…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11605    Accepted Submission(s): 4792 Problem Description There is a pile of n wooden sticks. The length and weight of each stick a…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19672    Accepted Submission(s): 7991 Problem Description There is a pile of n wooden sticks. The length and weight of each stick ar…
There is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in one by one fashion. It needs some time, called setup time, for the machine to prepare processing…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 12157    Accepted Submission(s): 5036 Problem Description There is a pile of n wooden sticks. The length and weight of each stick a…
先将火柴按照长度(或重量)优先排序,在不断遍历数组,找出其中重量(长度)递增子序列,并标记 Problem Description There is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in one by one fashion. It needs so…