麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

poj 2533 最大上升子序列

2019-11-11 04:58:28
字體:
來源:轉載
供稿:網友

A numeric sequence of ai is ordered if a1 < a2 < … < aN. Let the subsequence of the given numeric sequence ( a1, a2, …, aN) be any sequence ( ai1, ai2, …, aiK), where 1 <= i1 < i2 < … < iK <= N. For example, sequence (1, 7, 3, 5, 9, 4, 8) has ordered subsequences, e. g., (1, 7), (3, 4, 8) and many others. All longest ordered subsequences are of length 4, e. g., (1, 3, 5, 8).

Your PRogram, when given the numeric sequence, must find the length of its longest ordered subsequence. Input The first line of input file contains the length of sequence N. The second line contains the elements of sequence - N integers in the range from 0 to 10000 each, separated by spaces. 1 <= N <= 1000 Output Output file must contain a single integer - the length of the longest ordered subsequence of the given sequence. Sample Input 7 1 7 3 5 9 4 8 Sample Output 4 狀態轉移方程 dp[i] =max(dp[i],dp[j]+1);

#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;int dp[200000];int a[200000];int main(){ int n; while(cin>>n) { memset(dp,0,sizeof(dp)); if (n == 0) { printf ("1/n"); continue; } for(int i=1;i<=n;i++) { cin>>a[i]; dp[i]=1; } for(int i=1;i<=n;i++) { for(int j=i-1;j>0;j--) { if(a[i]>a[j]) dp[i]=max(dp[i],dp[j]+1); } } int ans=0; for(int i=1;i<=n;i++) ans=max(ans,dp[i]); printf("%d/n",ans ); }}
上一篇:ChucK初步(9)

下一篇:注解TXT

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 欧美aⅴ视频 | 国产一区二区三区在线免费 | 免费在线观看毛片 | 精品中文视频 | 免费a级毛片大学生免费观看 | 亚欧在线免费观看 | 99最新地址| 国产精品jk白丝蜜臀av软件 | 亚洲一区二区三区高清 | 日本欧美一区二区三区视频麻豆 | 黄色免费小网站 | 视频一区二区中文字幕 | 久久综合给合久久狠狠狠97色69 | 一级大黄毛片 | 国产精品99久久久久久久女警 | 9797色 | 免费国产一级淫片 | 色中色综合 | 成人在线观看免费视频 | 成人男男视频拍拍拍在线观看 | 国内精品久久久久久久影视红豆 | 成人网在线观看 | 男女亲热网站 | 日本精品黄色 | 成人在线视频国产 | 久久国产精品电影 | 精品国产一区二区三区四区阿崩 | 国产激情网 | 欧美激情猛片xxxⅹ大3 | 人人看人人艹 | 久久久久免费精品国产小说色大师 | 成人在线免费视频播放 | 亚洲精品午夜电影 | 日本高清视频网站www | 国产噜噜噜 | 欧美色另类 | 91成人免费网站 | 国产精品久久久久久久久久三级 | 久久久久久久高清 | 亚洲第一成人在线视频 | 精品国产三级a |