博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 1087
阅读量:4677 次
发布时间:2019-06-09

本文共 732 字,大约阅读时间需要 2 分钟。

动规  d[i]记录以第 i 个数结尾的最大值

#include 
#include
#include
#define maxn 1010using std::max;int dp[maxn];int value[maxn];int main(){ int n,_max; while(scanf("%d",&n) == 1 && n) { for(int i = 0; i < n; i++) { scanf("%d",&value[i]); } int _max = dp[0] = value[0]; for(int i = 1; i < n; i++) { dp[i] = value[i]; for(int j = 0; j < i; j++) { if(value[i] > value[j] && dp[i] < dp[j]+value[i]) dp[i] = dp[j]+value[i]; } _max = max(_max, dp[i]); } printf("%d\n",_max); } return 0;}

转载于:https://www.cnblogs.com/avema/p/3774324.html

你可能感兴趣的文章
CGRectGet *** 获取控件坐标的方法
查看>>
SQL的主键和外键约束
查看>>
Bookmarklet
查看>>
c++primer 第l六章编程练习答案
查看>>
上海秋季HCC小记
查看>>
Illustrator 上色
查看>>
truncate表恢复
查看>>
this关键字的使用
查看>>
Console.Read()、Console.ReadLine()、Console.ReadKey()
查看>>
ecere 编译过程中遇到的问题
查看>>
Cyclone V 与 Avalon-MM资料整理——DE1-SOC学习笔记(1)
查看>>
异常:This application has no explicit mapping for /error, so you are seeing this as a fallback.
查看>>
Flask-SQLAlchemy
查看>>
C# - Generics
查看>>
.NET LINQ 转换数据类型
查看>>
[LGP2791] 幼儿园篮球题
查看>>
170. Two Sum III - Data structure design
查看>>
os & sys
查看>>
Shell 常用命令总结
查看>>
vector
查看>>