zoukankan      html  css  js  c++  java
  • ACM Super Jumping! Jumping! Jumping!

    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. 

    InputInput 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. 
    OutputFor 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
     1 /*
     2     Name:  Super Jumping! Jumping! Jumping! 
     3     Copyright: 
     4     Author: 
     5     Date: 11/08/17 13:26
     6     Description: 访问棋子,下一步要访问的棋子要比目前的棋子的标记数要大,且不能返回,求最大数
     7                 用dp算法思想,用dp数组记录到目前的棋子的最优走法,直至最后一个棋子。 
     8 */
     9 
    10 #include<iostream>
    11 #include<cstring>
    12 #include<algorithm>
    13 using namespace std;
    14 const int NUM = 1005;
    15 int chessman[NUM],dp[NUM]; 
    16 int main()
    17 {
    18     int N,ans;
    19     while(cin>>N && N)
    20     {
    21         for(int i = 0; i < N; i++)
    22             cin>>chessman[i];
    23         
    24         dp[0] = chessman[0];
    25         ans = dp[0];
    26         for(int i = 1; i < N; i++)
    27         {
    28             dp[i] = chessman[i];
    29             for(int j = 0; j < i; j++)
    30             {
    31                 if(chessman[j] < chessman[i] && chessman[i] + dp[j] > dp[i])  /*dp思想*/ 
    32                     dp[i] = chessman[i] + dp[j];
    33                 
    34                 ans = max(ans,dp[i]);
    35             }
    36         }
    37         cout<<ans<<endl;
    38         
    39     }
    40     return 0;
    41 }
  • 相关阅读:
    嵌入式软件开发环境搭建与工具推荐
    软件常用设计原则与实践:契约式接口设计、安全编码实践
    服务器崩掉 ,只剩下挂载文件,重现github docker 容器
    基础巩固篇 —— CountDownLatch的理解
    基础巩固篇 —— 对锁的理解
    基础巩固篇 —— 对不安全集合的理解
    基础巩固篇 —— 对CAS的理解
    基础巩固篇 —— 对volatile关键字的理解
    响应式布局
    jQuery Mobile 网格
  • 原文地址:https://www.cnblogs.com/jj81/p/7267825.html
Copyright © 2011-2022 走看看