HDU 1087 Super Jumping! Jumping! Jumping!
2014-11-04 13:07
274 查看
这个题一看就是找一个 递增子序列。。 然后脑残的以为找 最长上升子序列。 在模板里面加上个 sum 数组递推上 过了样例就交上去了
获得了 WA之后。 自己出了一组数据 3 2 1 8 9 这五个数 最长上升子序列 有三个 3 89 或者 2 8 9 或者 1 8 9 然后就没法处理。
后来一想 应该是 上升子序列中找和最大的。 就写出 n^2 的递推公式了。 s【i】 = max (s【i】,s【j】 + a【i】) 其中 s【i】 代表以第i个数为结尾的最大和。
获得了 WA之后。 自己出了一组数据 3 2 1 8 9 这五个数 最长上升子序列 有三个 3 89 或者 2 8 9 或者 1 8 9 然后就没法处理。
后来一想 应该是 上升子序列中找和最大的。 就写出 n^2 的递推公式了。 s【i】 = max (s【i】,s【j】 + a【i】) 其中 s【i】 代表以第i个数为结尾的最大和。
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <string> #include <algorithm> #include <fstream> #include <set> #include <map> #include <queue> #include <stack> #include <list> #include <vector> #include <cmath> #include <iomanip> typedef long long LL; typedef unsigned long long LLU; const double PI=acos(-1.0); using namespace std; #define MAXN 1000+10 #define INF 1 << 30 int main (){ int n; while(scanf("%d",&n) && n){ LL a[MAXN]; LL s[MAXN] = {0}; for(int i = 1; i <= n; i++){ scanf("%I64d",&a[i]); s[i] = a[i]; } LL M = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= i; j++){ if(a[i] > a[j]) s[i] = max(s[i], s[j]+a[i]); } } for(int i = 1; i <= n; i++) M = max(M, s[i]); printf("%I64d\n",M); } return 0; }
相关文章推荐
- Hdu 1087 Super Jumping! Jumping! Jumping! (DP)
- HDU——1087 Super Jumping! Jumping! Jumping!
- Super Jumping! Jumping! Jumping! hdu1087
- 【HDU 1087】Super Jumping! Jumping! Jumping! (dp动态规划)
- Hdu 1087 - Super Jumping! Jumping! Jumping!
- hdu 1087 Super Jumping! Jumping! Jumping! 最大上升子序列。模板题
- hdu 1087 Super Jumping! Jumping! Jumping!
- HDU 1087 Super Jumping! Jumping! Jumping!
- hdu 1087 Super Jumping! Jumping! Jumping!(动态规划)
- 【hdu 1087】 Super Jumping! Jumping! Jumping! (LIS变形)
- HDU 1087 Super Jumping! Jumping! Jumping!
- HDU 1087 Super Jumping! Jumping! Jumping! 简单Dp
- HDU-1087(Super Jumping! Jumping! Jumping!)
- HDU 1087 Super Jumping! Jumping! Jumping! (动态规划)
- HDU 1087 Super Jumping! Jumping! Jumping!
- HDU 1087 Super Jumping! Jumping! Jumping!
- 每日三题-Day2-C(HDU 1087 Super Jumping! Jumping! Jumping! 最大上升子序列和)
- HDU-1087 Super Jumping! Jumping! Jumping!(上升子序列最大和)
- hdu 1087 Super Jumping! Jumping! Jumping!
- HDU1087 Super Jumping! Jumping! Jumping! DP求非连续单调递增序列的最大和