专题三--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.

1087-1.jpg


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. }




转载于:https://www.cnblogs.com/liuzhanshan/p/5529323.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
电气工作坊是一个旨在提供电气相关知识和技能的学习和实践平台。通过参与电气工作坊,学生将有机会学习电路原理、电气设备及系统的设计与安装、电气故障排除等方面的知识。电气工作坊通常会提供理论课程,如电路分析和电气安全等,以帮助学生建立正确的基本概念和技能。 在实践方面,电气工作坊通常会提供各种电气实验和项目。学生可以通过组装和调试电路板、设计和搭建小型电气系统等活动,提高他们的实际操作和解决问题的能力。这些实践项目不仅锻炼了学生的动手能力,还提供了他们将理论知识应用到实际问题中的机会。 专题设计是电气工作坊的一种教学形式。在专题设计中,学生可以选择特定的电气主题进行深入学习和探究。例如,学生可以选择学习电力系统的设计与规划,包括发电、输电和配电等方面的知识。学生还可以选择学习电机控制系统的设计与实施,包括电机的驱动、控制和保护等内容。专题设计可以让学生更加有针对性地学习和实践电气工程的相关知识和技能。 电气工作坊与专题设计为学生提供了一个实践学习电气工程的平台。通过参与这些活动,学生可以提高自己的专业知识和技能,为将来从事电气工程相关职业打下基础。此外,电气工作坊和专题设计也为学生提供了与同行和专家交流的机会,有助于拓宽他们的视野并提升他们的职业发展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值