HDU 1051(处理木棍 贪心)】的更多相关文章

题意是处理一批木棍,如果当前处理的木棍长度和重量均大于前一根木棍的长度和重量,则处理当前木棍花费为 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): 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): 23527    Accepted Submission(s): 9551 There is a pile of n wooden sticks. The length and weight of each stick are known in 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…
本题一看就知道是最长不减序列了,一想就以为是使用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<…
HDU 4442 Physical Examination(贪心) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=4442 Description WANGPENG is a freshman. He is requested to have a physical examination when entering the university. Now WANGPENG arrives at the hospital. Er-.. Th…
题目链接>>> 转载于:https://www.cnblogs.com/Action-/archive/2012/07/03/2574800.html  题目大意: 给n根木棍的长度和重量.根据要求求出制作木棍的最短时间.建立第一个木棍需要1分钟,若是接着要制作的木棍重量和长度都比此木棍长就不需要建立的时间,若是没有,则再需要建立时间.求时间最小为多少. 解题思路: 对木棍的长度和重量进行排序,以长度为首要考虑.排序完后的不一定都是下一根木棍重量和长度都大于前一根的.于是,我们对排序后的…
题目链接 一堆小木棍,每个有两个属性值(l,w),对小木棍分组,每一组内的小木棍存在这样一个序列满足s1<=s2<=s3.....<=sn,[s1<=s2当且仅当s1.l<=s2.l&&s1.w<=s2.w],问最小的分组数 ------------------------------------------------------------------------------------------ 贪心 #include <set> #…
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…