博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 1609 Tiling Up Blocks
阅读量:5153 次
发布时间:2019-06-13

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

Tiling Up Blocks
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 4675   Accepted: 1824

Description

Michael The Kid receives an interesting game set from his grandparent as his birthday gift. Inside the game set box, there are n tiling blocks and each block has a form as follows: 
Each tiling block is associated with two parameters (l,m), meaning that the upper face of the block is packed with l protruding knobs on the left and m protruding knobs on the middle. Correspondingly, the bottom face of an (l,m)-block is carved with l caving dens on the left and m dens on the middle. 
It is easily seen that an (l,m)-block can be tiled upon another (l,m)-block. However,this is not the only way for us to tile up the blocks. Actually, an (l,m)-block can be tiled upon another (l',m')-block if and only if l >= l' and m >= m'. 
Now the puzzle that Michael wants to solve is to decide what is the tallest tiling blocks he can make out of the given n blocks within his game box. In other words, you are given a collection of n blocks B = {b1, b2, . . . , bn} and each block bi is associated with two parameters (li,mi). The objective of the problem is to decide the number of tallest tiling blocks made from B. 

Input

Several sets of tiling blocks. The inputs are just a list of integers.For each set of tiling blocks, the first integer n represents the number of blocks within the game box. Following n, there will be n lines specifying parameters of blocks in B; each line contains exactly two integers, representing left and middle parameters of the i-th block, namely, li and mi. In other words, a game box is just a collection of n blocks B = {b1, b2, . . . , bn} and each block bi is associated with two parameters (li,mi). 
Note that n can be as large as 10000 and li and mi are in the range from 1 to 100. 
An integer n = 0 (zero) signifies the end of input.

Output

For each set of tiling blocks B, output the number of the tallest tiling blocks can be made out of B. Output a single star '*' to signify the end of 
outputs.

Sample Input

33 21 12 354 22 43 31 15 50

Sample Output

23* 题目大意:给定n个砖块的长和宽,只有当x2>=x1&&y2>=y1时 n2可以放在n1上 问最高能落多高。 解题方法:求最大不上升子序列,用动态规划。
#include 
#include
#include
using namespace std;int main(){ int w[105][105]; int dp[105][105]; int n; while(scanf("%d", &n) != EOF) { if (n == 0) { printf("*\n"); break; } int a, b; memset(w, 0, sizeof(w)); memset(dp, 0, sizeof(dp)); for (int i = 1; i <= n; i++) { scanf("%d%d", &a, &b); w[a][b]++; } for (int i = 1; i <= 100; i++) { for (int j = 1; j <= 100; j++) { dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + w[i][j]; } } printf("%d\n", dp[100][100]); } return 0;}

 

 

转载于:https://www.cnblogs.com/lzmfywz/p/3210882.html

你可能感兴趣的文章
UE4 使用UGM制作血条
查看>>
浏览器对属性兼容性支持力度查询网址
查看>>
OO学习总结与体会
查看>>
虚拟机长时间不关造成的问题
查看>>
校门外的树2 contest 树状数组练习 T4
查看>>
面试整理:Python基础
查看>>
Python核心编程——多线程threading和队列
查看>>
Program exited with code **** 相关解释
查看>>
植物大战僵尸中文年度版
查看>>
26、linux 几个C函数,nanosleep,lstat,unlink
查看>>
投标项目的脚本练习2
查看>>
201521123107 《Java程序设计》第9周学习总结
查看>>
Caroline--chochukmo
查看>>
利用jquery的contains实现搜索功能
查看>>
iOS之文本属性Attributes的使用
查看>>
从.Net版本演变看String和StringBuilder性能之争
查看>>
Excel操作 Microsoft.Office.Interop.Excel.dll的使用
查看>>
解决Ubuntu下博通网卡驱动问题
查看>>
【bzoj2788】Festival
查看>>
执行gem install dryrun错误
查看>>