首页 > ACM题库 > HDU-杭电 > hdu 3745 Block by Block待解决[解题报告]C++
2015
02-22

hdu 3745 Block by Block待解决[解题报告]C++

Block by Block

问题描述 :

Little Min Likes playing the "block by block" very much,she always plays it day and night.There are N types of blocks,each them have own Length and width of the bottom block and its height,we should place one block on the top another to build a tower and maximum the tower’s height.

Now we slight change in the next game.We place the blocks on the X-axis,every block has its begin coordinate si and end coordinate ei,which means the blocks’ positions are stable on the X-axis,at the same time, its height is 1 unit.The i-th block can place on the top of j-th only when si >= sj && ei <= ej,then we will build one tower by the new rule.
However,little Min thinks it is too easy for her,now she wants to better use of the number of blocks and the height of the tower she built can’t be more than H.that is to say,to build the tower with H high or less,the more blocks she use,the happier she is!
Note that two or more blocks can place on the same height except the bottom of the tower!
The sample will tells the details.

输入:

The first line contains an integer T, the number of test cases (T <= 20). Each test case is in the following format.
The first line starts with an integer N (1 <= N <= 300) denoting the number of Blocks and an integer H (1 <= H <= 10) denoting the highest height of the tower. Then following N lines, Each line contains two integer si and ei (0 < si < ei <= 500).

输出:

The first line contains an integer T, the number of test cases (T <= 20). Each test case is in the following format.
The first line starts with an integer N (1 <= N <= 300) denoting the number of Blocks and an integer H (1 <= H <= 10) denoting the highest height of the tower. Then following N lines, Each line contains two integer si and ei (0 < si < ei <= 500).

样例输入:

2
4 3
1 10
1 4
4 9
6 8
5 3
1 10
1 4
4 9
3 5
12 14

样例输出:

4
3


  1. 我们也不需要你负什么责任,不要再刷屏就好了。你觉得难受,不爽,就去报警吧。快去截图搜集证据。言尽于此,我不会再@你 或者对这件事发表评论,好自为之

  2. 我们也不需要你负什么责任,不要再刷屏就好了。你觉得难受,不爽,就去报警吧。快去截图搜集证据。言尽于此,我不会再@你 或者对这件事发表评论,好自为之

  3. 我们也不需要你负什么责任,不要再刷屏就好了。你觉得难受,不爽,就去报警吧。快去截图搜集证据。言尽于此,我不会再@你 或者对这件事发表评论,好自为之

  4. 我们也不需要你负什么责任,不要再刷屏就好了。你觉得难受,不爽,就去报警吧。快去截图搜集证据。言尽于此,我不会再@你 或者对这件事发表评论,好自为之

  5. 我们也不需要你负什么责任,不要再刷屏就好了。你觉得难受,不爽,就去报警吧。快去截图搜集证据。言尽于此,我不会再@你 或者对这件事发表评论,好自为之

  6. 我们也不需要你负什么责任,不要再刷屏就好了。你觉得难受,不爽,就去报警吧。快去截图搜集证据。言尽于此,我不会再@你 或者对这件事发表评论,好自为之

  7. 我们也不需要你负什么责任,不要再刷屏就好了。你觉得难受,不爽,就去报警吧。快去截图搜集证据。言尽于此,我不会再@你 或者对这件事发表评论,好自为之

  8. 我们也不需要你负什么责任,不要再刷屏就好了。你觉得难受,不爽,就去报警吧。快去截图搜集证据。言尽于此,我不会再@你 或者对这件事发表评论,好自为之

  9. 学算法中的数据结构学到一定程度会乐此不疲的,比如其中的2-3树,类似的红黑树,我甚至可以自己写个逻辑文件系统结构来。