"Algorithm Series learning" [Kuangbin you fly] topic 12 Basic DP1 E-super jumping! jumping! jumping!

Source: Internet
Author: User

Https://vjudge.net/contest/68966#problem/E

http://blog.csdn.net/to_be_better/article/details/50563344

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <string>5#include <algorithm>6#include <cmath>7 #defineINF 0x3f3f3f3f8 using namespacestd;9 intN;Ten Const intmaxn=1e3+Ten; One intA[MAXN]; A intDP[MAXN]; - intMain () - { the      while(SCANF ("%d", &n) = =1&&N) -     { -Memset (DP,0,sizeof(DP)); -          for(intI=1; i<=n;i++) +         { -scanf"%d",&a[i]); +         } A          for(intI=1; i<=n;i++) at         { -             intans=-INF; -              for(intk=0; k<i;k++) -             { -                 if(a[i]>A[k]) -                 { inans=Max (ans,dp[k]); -                 } to             } +dp[i]=ans+A[i]; -         } the         intans=-INF; *          for(intI=0; i<=n;i++) $         {Panax Notoginsengans=Max (ans,dp[i]); -         } theprintf"%d\n", ans); +     } A     return 0; the}
View Code

"Algorithm Series learning" [Kuangbin you fly] topic 12 Basic DP1 E-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.