HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(經典DP~)

      網友投稿 715 2025-04-04

      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

      就是找最大的遞增子序列!!!

      用動態(tài)規(guī)劃做~

      從前往后依次計算出當前遞增子序列的值~dp[i]

      最后找出最大的dp[i]就是答案~~

      import java.util.Scanner; /** * @author 陳浩翔 * * 2016-5-26 */ public class Main{ public static void main(String[] args) { Scanner sc =new Scanner(System.in); while(sc.hasNext()){ int n=sc.nextInt(); if(n==0){ break; } int a[]=new int[n]; int dp[]=new int[n]; for(int i=0;imax){ max=dp[j]; } } dp[i]=a[i]+max; } int max=dp[0]; for(int i=1;imax){ max=dp[i]; } } System.out.println(max); } } }

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(經典DP~)

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      29

      30

      31

      32

      33

      34

      35

      36

      37

      38

      39

      40

      41

      42

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實的內容,請聯(lián)系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實的內容,請聯(lián)系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:代號設置,就是當我在上一格輸入1時,下格自然顯示汽車,請問什么設置?
      下一篇:如何在Excel中僅串聯(lián)可見的單元格?
      相關文章
      一本色道久久88亚洲综合| 亚洲午夜福利在线视频| 亚洲国产精品不卡毛片a在线| 亚洲一区二区久久| 亚洲精品在线网站| 亚洲福利一区二区| 亚洲欧洲精品久久| 亚洲男人电影天堂| 亚洲高清日韩精品第一区| 亚洲福利视频一区二区三区| 亚洲视频免费一区| 亚洲最大的视频网站| 亚洲国产精品综合一区在线 | 亚洲美女大bbbbbbbbb| 内射少妇36P亚洲区| 久久亚洲国产成人精品性色| 亚洲一本综合久久| 亚洲欧洲日产韩国在线| 亚洲妇女水蜜桃av网网站| 亚洲人成片在线观看| 涩涩色中文综合亚洲| 亚洲国产精品ⅴa在线观看| 日本亚洲欧美色视频在线播放 | 苍井空亚洲精品AA片在线播放| 久久精品国产亚洲AV| 亚洲国产一区二区视频网站| 亚洲国产精品无码久久青草| 91麻豆精品国产自产在线观看亚洲 | 亚洲色欲或者高潮影院| 亚洲精品国产情侣av在线| 亚洲人成免费网站| 久久久久se色偷偷亚洲精品av| 国产精品亚洲综合久久| 亚洲成av人片在线天堂无| 亚洲精品色婷婷在线影院| 亚洲精品无码精品mV在线观看| 无码专区—VA亚洲V天堂| 老司机亚洲精品影院| 亚洲一区二区三区精品视频| 亚洲精品无播放器在线播放| 亚洲Aⅴ无码一区二区二三区软件 亚洲AⅤ视频一区二区三区 |