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
  • 相关阅读:
    [ Pytorch ] torch.squeeze() 和torch.unsqueeze()的用法
    莫烦
    毕业设计 Makefile 编写
    Manjaro搭建无密访问samba服务器
    GEC6818交叉开发环境搭建拟稿
    彻底删除windows残留启动引导
    Cmd Markdown 编辑阅读器
    Hi3519v101 SDK安装及升级
    Linux 修改SWAP分区后导致开机问题
    Linux 安装搭建 tftpd 服务器
  • 原文地址:https://www.cnblogs.com/crackpotisback/p/4036473.html
Copyright © 2011-2022 走看看