zoukankan      html  css  js  c++  java
  • DP专题训练之HDU 1087 Super Jumping!

    Description

    Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.



    The game can be played by two or more than two players. It consists of a chessboard(棋盘)and some chessmen(棋子), and all chessmen are marked by a positive integer or “start” or “end”. The player starts from start-point and must jumps into end-point finally. In the course of jumping, the player will visit the chessmen in the path, but everyone must jumps from one chessman to another absolutely bigger (you can assume start-point is a minimum and end-point is a maximum.). And all players cannot go backwards. One jumping can go from a chessman to next, also can go across many chessmen, and even you can straightly get to end-point from start-point. Of course you get zero point in this situation. A player is a winner if and only if he can get a bigger score according to his jumping solution. Note that your score comes from the sum of value on the chessmen in you jumping path.
    Your task is to output the maximum value according to the given chessmen list.
     

    Input

    Input contains multiple test cases. Each test case is described in a line as follow:
    N value_1 value_2 …value_N
    It is guarantied that N is not more than 1000 and all value_i are in the range of 32-int.
    A test case starting with 0 terminates the input and this test case is not to be processed.
     

    Output

    For each case, print the maximum according to rules, and one line one case.
     

    Sample Input

    3 1 3 2
    4 1 2 3 4
    4 3 3 2 1
    0
     

    Sample Output

    4
    10
    3

    求最大递增序列和~(不要求连续。。)

    看样例我以为是求最大连续递增序列和的说~~

    //Asimple
    #include <iostream>
    #include <sstream>
    #include <algorithm>
    #include <cstring>
    #include <cstdio>
    #include <vector>
    #include <cctype>
    #include <cstdlib>
    #include <stack>
    #include <cmath>
    #include <set>
    #include <map>
    #include <string>
    #include <queue>
    #include <limits.h>
    #include <time.h>
    #define INF 0xfffffff
    #define mod 1000000
    #define swap(a,b,t) t = a, a = b, b = t
    #define CLS(a, v) memset(a, v, sizeof(a))
    #define debug(a)  cout << #a << " = "  << a <<endl
    #define abs(x) x<0?-x:x
    #define srd(a) scanf("%d", &a)
    #define src(a) scanf("%c", &a)
    #define srs(a) scanf("%s", a)
    #define srdd(a,b) scanf("%d %d",&a, &b)
    #define srddd(a,b,c) scanf("%d %d %d",&a, &b, &c)
    #define prd(a) printf("%d
    ", a)
    #define prdd(a,b) printf("%d %d
    ",a, b)
    #define prs(a) printf("%s
    ", a)
    #define prc(a) printf("%c", a)
    using namespace std;
    typedef long long ll;
    const int maxn = 1002;
    int n, m, num, T, k, len, ans, sum;
    int dp[maxn], a[maxn];

    //不一定连续~~~ void input() { while( ~srd(n) && n ) { for(int i=0; i<n; i++) { srd(a[i]); } CLS(dp, 0); dp[0] = a[0]; for(int i=1; i<n; i++) { for(int j=0; j<i; j++) { if( a[i] > a[j]) dp[i] = max(dp[i], dp[j]+a[i]); } dp[i] = max(dp[i], a[i]); } ans = 0; for(int i=0; i<n; i++) { ans = max(ans, dp[i]); } prd(ans); } } int main(){ input(); return 0; }
    低调做人,高调做事。
  • 相关阅读:
    ossec配置使用腾讯企业邮箱告警
    网络排除工具之tcping
    pyenv 安装
    CVE-2020-1472 漏洞检测
    容器技术的核心
    简述 进程、线程、协程的区别 以及应用场景--记录
    php函数使用
    php使用表单post方法进行页面
    CURL方式使用代理访问网站
    nginx下隐藏admin和当前域名下得index.php
  • 原文地址:https://www.cnblogs.com/Asimple/p/6232736.html
Copyright © 2011-2022 走看看