博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 1051:Wooden Sticks
阅读量:7051 次
发布时间:2019-06-28

本文共 2345 字,大约阅读时间需要 7 分钟。

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 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 a stick. The setup times are associated with cleaning operations and changing tools and shapes in the machine. The setup times of the woodworking machine are given as follows: 
(a) The setup time for the first wooden stick is 1 minute. 
(b) Right after processing a stick of length l and weight w , the machine will need no setup time for a stick of length l' and weight w' if l<=l' and w<=w'. Otherwise, it will need 1 minute for setup. 
You are to find the minimum setup time to process a given pile of n wooden sticks. For example, if you have five sticks whose pairs of length and weight are (4,9), (5,2), (2,1), (3,5), and (1,4), then the minimum setup time should be 2 minutes since there is a sequence of pairs (1,4), (3,5), (4,9), (2,1), (5,2).
 

Input
The input consists of T test cases. The number of test cases (T) is given in the first line of the input file. Each test case consists of two lines: The first line has an integer n , 1<=n<=5000, that represents the number of wooden sticks in the test case, and the second line contains n 2 positive integers l1, w1, l2, w2, ..., ln, wn, each of magnitude at most 10000 , where li and wi are the length and weight of the i th wooden stick, respectively. The 2n integers are delimited by one or more spaces.
 

Output
The output should contain the minimum setup time in minutes, one per line.
 

Sample Input
 
3 5 4 9 5 2 2 1 3 5 1 4 3 2 2 1 1 2 2 3 1 3 2 2 3 1
 

Sample Output
 
2 1 3

简单贪心。。

题意能够看做是:给定若干(1<= n <=5000)组二维坐标点,凡是满足  "x1<= x2 && y1<= y2"的话那么我们承认这两个坐标是属于同一个集合中。题目要我们求出这些坐标点最少能表示成几个集合。

#include
#include
#include
#include
#include
#include
using namespace std;const int maxn = 5000 + 50;int cas;//案例int n;//木条数量int vis[maxn];//标记数组int ans_minute;//最短时间struct point{ int l;//长度 int w;//重量};point s[maxn];bool cmp(point a, point b){ if( a.l==b.l )return a.w
=n)break; } printf("%d\n", ans_minute); }}

转载地址:http://zrsol.baihongyu.com/

你可能感兴趣的文章
《PostgreSQL服务器编程》一一2.7 小结
查看>>
Oracle Database 12.2新特性详解
查看>>
IBM:量子计算现在跟1940年代电脑差不多 更看重长远目标
查看>>
研究机构称独角兽更易获得融资 明后年或有大量企业IPO
查看>>
三星将斥资80亿美元收购美国哈曼国际
查看>>
纷享销客变“逍”客 缘何战略一再调整?
查看>>
立标准引导市场化 大数据产业将迎“洗牌期”
查看>>
软件测试建模:Google ACC
查看>>
《 FreeSWITCH权威指南》——1.4 信令
查看>>
Netflix正在消灭传统电视网络
查看>>
eMarketer:物联网正在重塑快速消费品行业
查看>>
Deeplearning4j:如何建设深度学习开源社区
查看>>
移动安全身份认证厂商及产品盘点
查看>>
J2EE的13个规范
查看>>
记录-使用CSDN-markdown编辑器
查看>>
Windows 10将很快允许用户在未安装应用之前首先进行体验
查看>>
巧测字段最大长度
查看>>
TuShare(2):使用TuShare,抓取股票数据并存储到数据库
查看>>
还在跑分?什么样的固态硬盘才是好产品
查看>>
AI进入安防 安防的未来是怎样?
查看>>