HDU - 1087 Super Jumping! Jumping! Jumping!
Posted visualvk
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HDU - 1087 Super Jumping! Jumping! Jumping!相关的知识,希望对你有一定的参考价值。
input:
3 1 3 2 4 1 2 3 4 4 3 3 2 1 0
output:
4 10 3
题目大意:
寻找严格递增的序列和。
分析:
LIS。dp[i]表示前i个最长递增序列和。
code:
#define frp #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 0x3f3f3f3f; const ll inf = 0x7fffff; const int maxn = 1 << 15; const int MAXN = 10000; int dp[1001]; int n, chess[1001]; void solve() { while (cin >> n&&n) { for (int i = 0; i < n; i++) { cin >> chess[i]; } int ans = 0; for (int i = 0; i < n; i++) { dp[i] = chess[i]; for (int j = 0; j < i; j++) { if (chess[i] > chess[j]) { dp[i] = max(dp[i], dp[j] + chess[i]); } } ans=max(ans,dp[i]); } cout << ans << endl; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef frp freopen("D:\\coding\\c_coding\\in.txt", "r", stdin); // freopen("D:\\coding\\c_coding\\out.txt", "w", stdout); #endif solve(); return 0; }
以上是关于HDU - 1087 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!