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

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

poj 2533 最大上升子序列

2019-11-11 05:36:41
字體:
來源:轉載
供稿:網友

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 ); }}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 日本网站一区二区三区 | 欧美性色黄大片www 成人免费网站在线观看 | 亚州成人在线观看 | h视频在线观看免费 | 日本在线播放一区二区 | 久久国产免费 | 久久生活片 | 成人午夜在线免费观看 | 成人黄色小视频在线观看 | 久久精品亚洲精品国产欧美kt∨ | 成人毛片免费 | 免费毛片观看 | 国产成人自拍小视频 | 爱操视频| 亚洲午夜在线观看 | 国产黄色免费网站 | 91毛片网站 | 亚洲成人入口 | 欧美亚州| 毛片免费视频观看 | avlululu| 久久96国产精品久久久 | 国产日韩a| 久久国产精品一区 | 在线91视频 | 91午夜免费视频 | 九九热在线视频观看这里只有精品 | 黄色片网站免费看 | 激情91 | 精品在线视频播放 | 中文字幕在线视频日本 | 成人做爽爽爽爽免费国产软件 | 福利一区二区三区视频在线观看 | 黄色免费在线电影 | 久久久久久久一区二区 | 免费一级毛片在线播放视频老 | 一级做a爱片性色毛片高清 国产精品色在线网站 | 亚洲日本欧美 | 国产艳妇av视国产精选av一区 | 国产91丝袜在线播放 | 97久久精品一区二区三区观看 |