1422 - Halloween Costumes   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Gappu has a very busy weekend ahead of him. Because, next weekend is Halloween, and he is planning to attend as many parties as he can. Since it's…
题目链接:https://vjudge.net/problem/LightOJ-1422 1422 - Halloween Costumes    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Gappu has a very busy weekend ahead of him. Because, next weekend is Halloween, and he is planning to…
题意:给你n天需要穿的衣服的样式,每次可以套着穿衣服,脱掉的衣服就不能再穿了,问至少要带多少条衣服才能参加所有宴会 思路:dp[i][j]代表i-j天最少要带的衣服 从后向前dp 区间从大到小 更新dp[i][j]时有两种情况 考虑第i天穿的衣服 1:第i天穿的衣服在之后不再穿了 那么 dp[i][j]=dp[i+1][j]+1; 2:第i天穿的衣服与i+1到j的某一天共用,那么dp[i][j]=min(dp[i][j],dp[i+1][k-1],dp[k][j]),前提是第i天和第k天需要的礼…
题目链接:http://vjudge.net/contest/141291#problem/D 题意:有n个地方,每个地方要穿一种衣服,衣服可以嵌套穿,一旦脱下的衣服不能再穿,除非穿同样的一件新的,问在满足题目要求的穿衣顺序下最少需要准备几件衣服. 思路:区间dp //这个是看的别人的代码理解的,但是按照自己理解的写的代码样例正确,但是结果怎么都是WA的,不知道为什么,等我问问学长搞懂了再补题.//隔天改对了. 代码1: #include<iostream> #include<cstdi…
http://www.cnblogs.com/kuangbin/archive/2013/04/29/3051392.html http://www.cnblogs.com/ziyi--caolu/archive/2013/08/01/3229668.html http://www.cfanz.cn/index.php?c=article&a=read&id=172173 #include <iostream> #include <string> #include…
题 题意 告诉我们每天要穿第几号衣服,规定可以套好多衣服,所以每天可以套上一件新的该号衣服,也可以脱掉一直到该号衣服在最外面.求最少需要几件衣服. 分析 DP,dp[i][j]表示第i天到第j天不脱第i天之前的衣服最少需要的衣服数量,那就可以由和第j天穿一样的衣服的第k天转移过来,或者再套一件第j天的衣服. 状态转移方程:dp[i][j]=min(dp[i][k]+dp[k+1][j-1],dp[i][j-1]+1)(i≤k<j,a[j]==a[k]) 算的时候i从大到小算,因为算dp[i][j…
B - Halloween Costumes Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1422 Description Gappu has a very busy weekend ahead of him. Because, next weekend is Halloween, and he is planning to attend as…
http://lightoj.com/volume_showproblem.php?problem=1422 做的第一道区间DP的题目,试水. 参考解题报告: http://www.cnblogs.com/ziyi--caolu/p/3236035.html http://blog.csdn.net/hcbbt/article/details/15478095 dp[i][j]为第i天到第j天要穿的最少衣服,考虑第i天,如果后面的[i+1, j]天的衣服不要管,那么dp[i][j] = dp[i…
Description Gappu has a very busy weekend ahead of him. Because, next weekend is Halloween, and he is planning to attend as many parties as he can. Since it's Halloween, these parties are all costume parties, Gappu always selects his costumes in such…
区间dp的第一题----- 看题解看了好多~~终于看懂了---55555 dp[i][j] 表示第i天到第j天至少需要多少件衣服 那么第i件衣服只被第i天占用的话, dp[i][j] = dp[i+1][j] + 1 如果不只被第i天占用的话,那么假设在第k天和第i天穿一样的衣服,dp[i][j] = dp[i+1][k-1] + dp[k][j] 这一篇讲得很详细~ http://blog.csdn.net/tc_to_top/article/details/44830317 #include…