[HDOJ1087] Super jumping! jumping! jumping!

Source: Internet
Author: User

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1087

is to seek the longest ascending subsequence, but the result is the and of the sequence, the transfer equation: dp[i] = max (Dp[i], dp[j]+a[i])

1#include <cstdio>2#include <cstdlib>3#include <cstring>4#include <algorithm>5#include <iostream>6#include <cmath>7#include <queue>8#include <map>9#include <Set>Ten#include <stack> One#include <list> A#include <vector> -  - using namespacestd; the  -InlineintMaxintAintb) { -     returna > B?a:b; - } + Const intMAXN =1010; - intN; + intA[MAXN]; A intDP[MAXN]; at intans; - intMain () { -     //freopen ("in", "R", stdin); -      while(~SCANF ("%d", &n) &&N) { -Ans =0; -          for(inti =0; I < n; i++) { inscanf"%d", &a[i]); -         } to          for(inti =0; I < n; i++) { +Dp[i] =A[i]; -              for(intj =0; J < I; J + +) { the                 if(A[j] <A[i]) { *Dp[i] = max (Dp[i], dp[j] +a[i]); $                 }Panax Notoginseng             } -Ans =Max (ans, dp[i]); the         } +printf"%d\n", ans); A     } the}

[HDOJ1087] Super jumping! jumping! jumping!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.