Super jumping! jumping! Jumping!---hdu1087 (Dynamic planning)

Source: Internet
Author: User

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

Test instructions is to give you the number of N, find out a sequence of the largest and, this sequence to meet the rules of increasing in turn;

Ah, this problem has been done before, but a little impression is not but their own writing out, it is estimated that at that time did not know why write it, it turns out that the problem is more natural to understand;

I did it with the idea of ascending the subsequence.

#include <stdio.h>#include<string.h>#include<algorithm>using namespacestd;#defineN 1100#defineINF 0XFFFFFFFintMain () {intN, A[n], dp[n], Max;  while(SCANF ("%d", &N) {memset (A,0,sizeof(a)); Memset (DP,0,sizeof(DP));  for(intI=1; i<=n; i++) {scanf ("%d", &A[i]); } Max=0;  for(intI=1; i<=n; i++) {Dp[i]=A[i];  for(intj=1; j<=i; J + +)            {                if(a[i]>A[j]) dp[i]= Max (Dp[i], dp[j]+A[i]); } Max=Max (max, dp[i]); } printf ("%d\n", Max); }    return 0;}
View Code

Super jumping! jumping! Jumping!---hdu1087 (Dynamic planning)

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.