HDu1087 Super Jumping! Jumping! Jumping!

Posted veasky

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HDu1087 Super Jumping! Jumping! Jumping!相关的知识,希望对你有一定的参考价值。

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087

分析:简单dp;dp[i] = max (dp[i], dp[j] + a[i])

 1 #include<iostream>
 2 #include<sstream>
 3 #include<cstdio>
 4 #include<cstdlib>
 5 #include<string>
 6 #include<cstring>
 7 #include<algorithm>
 8 #include<functional>
 9 #include<iomanip>
10 #include<numeric>
11 #include<cmath>
12 #include<queue>
13 #include<vector>
14 #include<set>
15 #include<cctype>
16 #define PI acos(-1.0)
17 const int INF = 0x3f3f3f3f;
18 const int NINF = -INF - 1;
19 const int maxn = (1 << 15) + 10;
20 typedef long long ll;
21 using namespace std;
22 int n;
23 int arr[1005];
24 int dp[1005];
25 int main()
26 
27     while (scanf("%d", &n) && n)
28     
29         for (int i = 0; i < n; ++i)
30             scanf("%d", &arr[i]);
31         for (int i = 0; i < n; ++i) dp[i] = arr[i];
32         for (int i = 0; i < n; ++i)
33         
34             for (int j = 0; j < i; ++j)
35             
36                 if (arr[i] > arr[j])
37                     dp[i] = max(dp[i], dp[j] + arr[i]);
38             
39         
40         int ans = 0;
41         for (int i = 0; i < n; ++i)
42             ans = max(ans, dp[i]);
43         printf("%d\n", ans);
44     
45     return 0;
46 

 

以上是关于HDu1087 Super Jumping! Jumping! Jumping!的主要内容,如果未能解决你的问题,请参考以下文章

Super Jumping! Jumping! Jumping! HDU - 1087

HDU-1087 Super Jumping! Jumping! Jumping!

HDU 1087Super Jumping! Jumping! Jumping!

HDU 1087 Super Jumping! Jumping! Jumping!

HDU 1087 Super Jumping! Jumping! Jumping!

HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)