zoukankan      html  css  js  c++  java
  • 专题三--1003

    题目

    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
    
    

    题目大意

    跳棋只能从分数小的棋子跳向分数大的棋子,求最大得到的分数(跳过棋子上的分数和)
    英语战五渣表示这个英语题目很坑啊。。。憋了很长时间
    是一个简单的求最大上升子列和的模板题

    AC代码

    1. #include<iostream>
    2. #include<stdio.h>
    3. #include<string.h>
    4. using namespace std;
    5. inline int MAX(int a, int b){
    6. return a > b ? a : b;
    7. }
    8. int a[1010];
    9. int dp[1010];
    10. int main(){
    11. //freopen("date.in","r",stdin);
    12. //freopen("date.out","w",stdout);
    13. int N, maxs, maxr,s;
    14. while (cin >> N&&N != 0){
    15. memset(dp, 0, sizeof(dp));
    16. for (int i = 1; i<=N; i++){
    17. cin >> a[i];
    18. }
    19. dp[1] = a[1];
    20. maxr = a[1];
    21. for (int k = 2; k <= N; k++){
    22. maxs = -999999999;
    23. s = 1;
    24. for (int l = 1; l<k; l++){
    25. if (a[k]>a[l]){
    26. maxs = MAX(maxs, dp[l]);
    27. s = l;
    28. }
    29. dp[k] = maxs + a[k];
    30. }
    31. /*if (dp[k]>maxr)
    32. maxr = dp[k];*/
    33. }
    34. maxr = -999999999;
    35. for (int i = 1; i <= N; i++){
    36. if (dp[i] > maxr)
    37. maxr = dp[i];
    38. }
    39. /*for(int i=1;i<=N;i++){
    40. cout<<dp[i]<<endl;
    41. }*/
    42. cout << maxr << endl;
    43. }
    44. }




  • 相关阅读:
    常用的 写代码 的 指令
    boos
    超级搬运工
    那些年,我读过的书籍(读完一本就在此处更新),立贴。
    ExtJs combobox模糊匹配
    整理了一下eclipse 快捷键注释的一份文档
    中国省份按照拼音排序出现的问题以及临时解决方案
    JetBrains WebStorm 安装破解问题
    ExtJs Grid 删除,编辑,查看详细等超链接处理
    ExtJs Panel 滚动条设置
  • 原文地址:https://www.cnblogs.com/liuzhanshan/p/5529323.html
Copyright © 2011-2022 走看看