zoukankan      html  css  js  c++  java
  • HDU 1087

    Super Jumping! Jumping! Jumping!

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


    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
     1 //最大上升子序列和 
     2 #include <iostream>
     3 using namespace std;
     4 
     5 int a[1001],b[1001];
     6 int num;
     7 
     8 int main()
     9 {
    10     int i,j,k;
    11     int ans,res;
    12     while (cin>>num,num)
    13     {
    14         for (i=0;i<num;i++)
    15         {
    16             cin>>a[i];
    17             b[i]=-1;
    18         }
    19         res=-1;
    20         for (i=num-1;i>=0;i--)
    21         {
    22             ans=0;
    23             for (j=i+1;j<num;j++)
    24             {
    25                 if(a[j]>a[i]&&b[j]>ans)
    26                     ans=b[j];
    27             }
    28             b[i]=a[i]+ans;
    29             res=res>b[i]?res:b[i];
    30         }
    31        cout<<res<<endl;
    32     }
    33     return 0;
    34 }
    View Code
     1 //因为不一定连续 下面的wa 
     2  #include <iostream>
     3  using namespace std;
     4  
     5  int a[1001];
     6  int num;
     7  
     8  int main()
     9  {
    10      int i,j,k;
    11      int ans,res;
    12      while (cin>>num,num)
    13      {
    14          for (i=0;i<num;i++)
    15          {
    16              cin>>a[i];
    17          }
    18          res=-1;
    19          for (i=0;i<num;i++)
    20          {
    21              ans = a[i];
    22              for (j=i+1;j<num;j++)
    23              {
    24                  if(a[j]>a[])
    25                      ans+=a[j];
    26                else
    27                     break;
    28              }
    29              res=res>ans?res:ans;
    30          }
    31         cout<<res<<endl;
    32      }
    33      return 0;
    34  }
    View Code
     1 const int N=1005;
     2 int a[N];
     3 int sum[N]; //sum(i)以a[i]结尾的数列的和 保存的最大值
     4 int main(){
     5    int t,n,i,x,k,m,j,v,Max,temp,end,start,flag;
     6    while(cin>>n&&n){
     7      //memset(sum,0,sizeof(sum));
     8      Max=-1000000000;
     9      for(i=1;i<=n;i++){
    10         scanf("%d",&a[i]);
    11         sum[i]=a[i]; // 初始化,以a[i]结尾的和,就一个为自己
    12      }
    13      for(i=1;i<=n;i++){
    14       for(j=1;j<i;j++){
    15         if(a[j]<a[i]&&sum[j]+a[i]>sum[i]) //a[j]在a[i]左边,且a[i]大,
    16            sum[i]=sum[j]+a[i];
    17       }
    18      if(sum[i]>Max)  //记录最大值
    19        Max=sum[i];
    20    }
    21    cout<<Max<<endl;
    22    }
    23   return 0;
    24 }
  • 相关阅读:
    ubuntu 安装 less
    Django orm增删改字段、建表 ,单表增删改查,Django请求生命周期
    python RabbitMQ队列使用
    80个Python练手项目列表
    celery异步任务体系笔记
    为什么要选择RabbitMQ ,RabbitMQ简介,各种MQ选型对比
    吞吐量(TPS)、QPS、并发数、响应时间(RT)
    Supervisor使用详解
    supervisor 使 celery后台运行
    celery Django 简单示例
  • 原文地址:https://www.cnblogs.com/hxsyl/p/2671751.html
Copyright © 2011-2022 走看看