zoukankan      html  css  js  c++  java
  • HDU 1087 Super Jumping! Jumping! Jumping!

    Super Jumping! Jumping! Jumping!

    Time Limit: 1000ms
    Memory Limit: 32768KB
    This problem will be judged on HDU. Original ID: 1087
    64-bit integer IO format: %I64d      Java class name: Main
     
    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

    解题:类似最长上升子序列,不过还是有点区别。。。哎。。。dp太弱,补点dp,娱乐娱乐一下

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <cmath>
     5 #include <algorithm>
     6 #include <climits>
     7 #include <vector>
     8 #include <queue>
     9 #include <cstdlib>
    10 #include <string>
    11 #include <set>
    12 #include <stack>
    13 #define LL long long
    14 #define pii pair<int,int>
    15 #define INF 0x3f3f3f3f
    16 using namespace std;
    17 const int maxn = 1010;
    18 int dp[maxn],d[maxn],n;
    19 int main() {
    20     while(scanf("%d",&n),n){
    21         for(int i = 0; i < n; ++i)
    22             scanf("%d",d+i);
    23         memset(dp,0,sizeof(dp));
    24         int ans = 0;
    25         for(int i = 0; i < n; ++i){
    26             dp[i] = d[i];
    27             for(int j = i-1; j >= 0; --j)
    28                 if(d[j] < d[i] && dp[j] + d[i] > dp[i]) dp[i] = dp[j] + d[i];
    29             ans = max(ans,dp[i]);
    30         }
    31         printf("%d
    ",ans);
    32     }
    33     return 0;
    34 }
    View Code
  • 相关阅读:
    中文编解码问题
    转载:深入探讨 Java 类加载器
    转载:MAT Memory Analyzer Tool使用示例
    转载:MyEclipse安装插件的几种方法
    React组件之间通过Props传值的技巧(小案例,帮助体会理解props、state、受控组件和非受控组件等)
    ES5, ES6, ES2016, ES.Next: JavaScript 的版本是怎么回事?
    GIT,SVN,CVS的区别比较
    JS实现拖拽小案例
    JS实现时钟效果
    关于VUE的安装和一些简单属性
  • 原文地址:https://www.cnblogs.com/crackpotisback/p/4036473.html
Copyright © 2011-2022 走看看