HDU1087】的更多相关文章

题意:给定一串数字,要求选取一个严格递增的子序列,使序列和最大. dp[i] 表示以 i 为结尾的子序列的最大和,dp[i] = max{dp[j]+a[i]}(j 从 0 到 i-1),dp[0]是0: #include<stdio.h> #include<string.h> #define max(a,b) a>b?a:b ]; ]; int main(){ int n; ){ int q,i,j; ; ;q<=n;q++){ scanf("%d"…
http://acm.split.hdu.edu.cn/showproblem.php?pid=1087 状态方程:sum[j]=max{sum[i]}+a[j]; 其中,0<=i<=j,a[i]<a[j] 把当前最大和更新到数组中,注意顺序. Input Input contains multiple test cases. Each test case is described in a line as follow:N value_1 value_2 …value_N It is…
题意概括:在上次与娑殚的三次博弈中,你们都取得了胜利.便向娑殚提出要求,借助他的力量,传送到一个安全的地方. 你们的愿望达成了,不过,你和小A似乎失散了. 街上人来人往的特别热闹,每一个人的脸上都洋溢着幸福.“咕咕......"额,掏了掏身上的口袋,除你之外. “听说了嘛,德源街哪有个脑力比赛,据说优胜者可以去”吃到饱“饭店吃到饱,而且前三名还会有神秘奖品......" 这次,为了填饱......嗯,为了生存,你决定参加这个比赛,比赛要求你得到在给定的数字中得到最大循序上升序列和. 问…
I - 简单dp 例题扩展 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HD…
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a…
Problem Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now. The game can be played by two or more than t…
#include<map> #include<set> #include<list> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 题目大意: 求递增子序列最大和 思路: 直接dp就可以求解,dp[i]表示以第i位结尾的递增子序列最大和,初始化dp[i] = a[i],转移方程dp[i] = max(dp[i], a[i] + dp[j])如果j < i && a[j] < a[i] #include<cstdio> #include<cstring> #include<i…
本题大意:给定一个长度为n的序列a,让你输出这个序列子序列中元素和最大的最大上升子序列. 本题思路:一开始肯定可以想到用LIS实现,我们用LIS实现的时候可以发现这个问题并不满足LIS问题的最优子结构,即两者的子问题肯定是不相同的...比如5 2 2 2 1 2 3,在这五个数中,如果按照LIS你会发现dp[3] = 2 ,dp[ 4] = 2,那么dp[5]呢,dp[5] = 3,刚好是不满足LIS求解的性质的,也就是违反了LIS的最优子结构性质,那么我们要如何才能得到另一份最优子结构呢,我看…
题意,给出一列数,要求所有上升子序列中序列和最大的. 这回不是求长度了,但是还是相当基础的 dp 水题,只要用 dp [ q ] 记录以 第 q 个数 a [ q ] 为结尾的上升子序列的最大的和就可以了 对于 q ,初始化 dp [ q ] = a [ q ] ,从最前面到 q 遍历,若有第 i 个数 a [ i ] < a [ q ] ,则 dp [ q ] = max ( dp [ q ] , dp [ i ] + a [ q ] ): 这样 dp 一遍并同时记录下最大值,就可以直接输出结…