
动态规划
Hawkeye_z
不足之处请多多指教
展开
-
最长递增子序列(O(nlogn))
使用最基础的方法计算最长递增子序列的时间复杂度为O(n^2), 在n值过大时,肯定会超时。因此,在这里介绍一种优化算法。 维护一个一维数组dp,dp[i]表示最长上升子序列长度是i的所有子串中末尾最小的那个数,根据这个数字,我们可以比较知道,只要当前考察的这个数比dp[i]大,那么当前这个数一定能通过dp[i]构成一个长度为i+1的上升子序列。当然我们希望在dp数组中找一个尽量靠后的数字,这样我原创 2015-08-15 10:23:40 · 613 阅读 · 0 评论 -
HDU 2571 命运(DP)
HDU 2571 命运原创 2015-08-03 19:54:40 · 567 阅读 · 0 评论 -
Poj1037 A decorative fence(DP好题)
题目链接:http://poj.org/problem?id=1037 题意:给你N个板子,每个板子长度都不一样。长度为1~n,使板子排列成波浪形,即对于对于1#include <iostream>#include<algorithm>#include<cstring>using namespace std;#define LL long longLL dp[25][25][2];//0原创 2016-03-23 16:29:32 · 798 阅读 · 0 评论 -
poj1088 滑雪(简单dp)
题目链接:http://poj.org/problem?id=1088 简单的搜索一遍就ok#include<iostream>#include<algorithm>#include<cstring>using namespace std;int Div[4][2]={{-1,0},{0,-1},{0,1},{1,0}};int len[105][105];int maze[105][原创 2016-03-25 17:06:38 · 418 阅读 · 0 评论