poj 1836 Alignment(线性dp)】的更多相关文章

题目: http://poj.org/problem?id=1836 没读懂题,以为身高不能有相同的,没想到排中间的两个身高是可以相同的.. #include <stdio.h> #include <string.h> #include <iostream> ], dpl[]; int main() { int n; ]; while(scanf("%d", &n) != EOF) { ; i <= n; i++) { std::cin…
Alignment Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 14486   Accepted: 4695 Description In the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are aligned in a straight line in front of the cap…
Maximum sum Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 33918   Accepted: 10504 Description Given a set of n integers: A={a1, a2,..., an}, we define a function d(A) as below: Your task is to calculate d(A). Input The input consists o…
题目链接:http://poj.org/problem?id=1836 思路分析:假设数组为A[0, 1, …, n],求在数组中最少去掉几个数字,构成的新数组B[0, 1, …, m]满足条件B[0] < B[1] <….<B[i] 且 B[i+1] > … > B[m]; 该问题实质为求A[0, …, k]的最长递增子序列和A[j, …, n]中的最长递减子序列(0 <= k <= n, 0 <= j <= n, k < j);所以求出A[0…
题目:http://poj.org/problem?id=1836 题意:最长上升子序列问题, 站队,求踢出最少的人数后,使得队列里的人都能看到 左边的无穷远处 或者 右边的无穷远处. 代码O(n^2): #include<iostream> #include<cstring> using namespace std; int main() { ],d2[],mx; ]; cin>>n; ; i<=n; i++) cin>>a[i]; d1[]=; ;…
Alignment Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10804   Accepted: 3464 Description In the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are aligned in a straight line in front of the cap…
Alignment Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 11450 Accepted: 3647 Description In the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are aligned in a straight line in front of the captain…
题目链接:http://poj.org/problem?id=3356 思路分析:题目为经典的编辑距离问题,其实质为动态规划问题: 编辑距离问题定义:给定一个字符串source,可以对其进行复制,替换,删除,增加操作,另外根据具体情况已经规定了每种操作的cost,现在要求求出一个操作序列,使其变为一个给定的字符串dest,并且该操作序列的cost的和最小(在该题目中复制开销为0,其他开销为1): 该问题为动态规划问题,先对该问题进行分析: 1)发掘最优子结构: 假设源字符串为S[0, 1, 2,…
Divisibility Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 10598   Accepted: 3787 Description Consider an arbitrary sequence of integers. One can place + or - operators between integers in the sequence, thus deriving different arithmet…
大致题意:给出一队士兵的身高,一开始不是按身高排序的.要求最少的人出列,使原序列的士兵的身高先递增后递减. 求递增和递减不难想到递增子序列,要求最少的人出列,也就是原队列的人要最多. 1 2 3 4 5 4 3 2 1 这个序列从左至右看前半部分是递增,从右至左看前半部分也是递增.所以我们先把从左只右和从右至左的LIS分别求出来. 如果结果是这样的: A[i]={1.86 1.86 1.30621 2 1.4 1 1.97 2.2} //原队列 a[i]={1 1 1 2 2 1 3 4} b[…