POJ 2533
来源:互联网 发布:网络攻击手段 编辑:程序博客网 时间:2024/05/16 17:41
题目大意:求最长递增子序列的长度。
解题思路:每个dp初始为1。第一个循环位置从0到n,判断,如果之后的有比该位置大的,就去判断后位置的dp大小。dp[j] = max(dp[j], dp[i]+1);
ac代码:
#include <iostream>#include <algorithm>using namespace std;int dp[1005], n, a[1005], Max;int main(){while (scanf("%d", &n) != EOF){for (int i=0; i<n; i++){scanf("%d", &a[i]);dp[i] = 1;}for (int i=0; i<n; i++)for (int j=i+1; j<n; j++)if (a[i] < a[j])dp[j] = max(dp[j], dp[i]+1);Max = dp[0];for (int i=1; i<n; i++)Max = max(Max, dp[i]);printf("%d\n", Max);}return 0;}
阅读全文
0 0
- POJ 2533
- POJ 2533
- POJ 2533
- poj 2533
- POJ 2533
- poj-2533
- poj--2533
- poj 2533
- POJ 2533
- POJ 2533
- POJ 2533
- poj 2533
- POJ-2533
- POJ 2533
- POJ 2533
- POJ 2533
- POJ 2533 O(NLogN)
- poj 2533 LCS
- Android 自定义相机页面
- 比赛4 总结
- 1159:青年歌手大奖赛-评委会打分
- JDBC数据库连接池
- 关于分布式事务、两阶段提交协议、三阶提交协议
- POJ 2533
- Javascript正则表达式
- 倒计时调转:
- jquery ajax jsonp跨域调⽤实例代码
- 第十六节:加载Firefox配置
- 人生困苦9/6
- 荷混凝柱截StructureРoint spColumn 5.50 1CD载筋
- Expect详解
- 第二章、对象及变量的并发访问 之 synchronized 同步方法(1)