zoukankan      html  css  js  c++  java
  • 【hdu 1087 (Super Jumping! Jumping! Jumping!) 巨水动规题,,被坑!!】

    Super Jumping! Jumping! Jumping!

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 13056    Accepted Submission(s): 5420


    Problem 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
     
    Author
    lcy
     
     
     
     
    =========================================================================================================================================
    看完题目就知道不是什么好货色,反正刚到实验室,就当热身咯。。写完马上提交。
    有菜鸟刷水题的意思。。罪过罪过。
     
     1 // Project name : 1087 ( Super Jumping! Jumping! Jumping! ) 
     2 // File name    : main.cpp
     3 // Author       : iCoding
     4 // E-mail       : honi.linux@gmail.com
     5 // Date & Time  : Wed Aug  8 11:19:00 2012
     6 
     7 
     8 #include <iostream>
     9 #include <stdio.h>
    10 #include <string>
    11 #include <cmath>
    12 #include <algorithm>
    13 using namespace std;
    14 
    15 /*******************************************************************************/
    16 /*data*/
    17 #define MAXN 2000
    18 
    19 int iMap[MAXN];
    20 int iSum[MAXN];
    21 
    22 int n;
    23 
    24 /*******************************************************************************/
    25 /*procedure*/
    26 void iInit()
    27 {
    28     for (int i = 0; i < n; i++)
    29     {
    30         cin >> iMap[i];
    31     }
    32 }
    33 
    34 void iDynamicProgramming()
    35 {
    36     for (int i = 0; i < n; i++)
    37     {
    38         int iMax = 0;
    39         for (int j = 0; j < i; j++)
    40         {
    41             if (iMap[j] < iMap[i] && iSum[j] > iMax)
    42             {
    43                 iMax = iSum[j];
    44             }
    45         }
    46         iSum[i] = iMap[i] + iMax;
    47     }
    48 }
    49 
    50 void iShowResult()
    51 {
    52     int iMax = 0;
    53     for (int i = 0; i < n; i++)
    54     {
    55         if (iSum[i] > iMax)
    56         {
    57             iMax = iSum[i];
    58         }
    59     }
    60     cout << iMax << endl;
    61 }
    62 /*******************************************************************************/
    63 /*main*/
    64 int main()
    65 {
    66     while (cin >> n && n > 0)
    67     {
    68         iInit();
    69         iDynamicProgramming();
    70         iShowResult();
    71     }
    72     return 0;
    73 }
    74 
    75 // end 
    76 // Code by Sublime text 2
    77 // iCoding@CodeLab 
  • 相关阅读:
    JavaScript学习总结(八)——JavaScript数组
    oracle数据库优化学习笔记
    把连续日期组织起来的算法
    转:andriod的盈利模式分析
    ASP.NET 页生命周期
    .NET垃圾回收机制[引用]
    IIS 7.0 的 ASP.NET 应用程序生命周期
    table滑动选择行及从表记录对应js代码
    hdu 3594 Cactus
    Java 计算器
  • 原文地址:https://www.cnblogs.com/ismdeep/p/2627933.html
Copyright © 2011-2022 走看看