编程介的小学生 2019-06-20 20:45 采纳率: 20.5%
浏览 162

建造一座塔楼并最大化塔楼的高度使用的积木的计算,怎么采用C语言的代码的编写的过程来实现的呢

Problem Description
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.

Input
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).

Output
For each test case, print one line containing one integer S meaning the maximum number of blocks she can use to build one tower.

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

Sample Output
4
3

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 mmocr的训练错误,结果全为0
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀