LIS
来源:互联网 发布:淘宝卖家需要哪些软件 编辑:程序博客网 时间:2024/05/01 10:42
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>using namespace std;const int maxn=1e5+10;int n,a[maxn],dp1[maxn],dp2[maxn];int main(){ int t; scanf("%d",&t); while(t--) { while(~scanf("%d",&n)) { if(n==0)break; memset(dp1,0,sizeof(dp1)); memset(dp2,0,sizeof(dp2)); for(int i=1; i<=n; i++) { scanf("%d",&a[i]); } for(int i=1; i<=n; i++) { for(int j=i-1; j>=0; j--) { if(a[i]>a[j]) dp1[i]=max(dp1[i],dp1[j]+1); } } for(int i=1; i<=n; i++) { for(int j=1; j<i; j++) { if(a[i]<a[j]) dp2[i]=max(dp2[i],dp2[j]+1); } } sort(dp1+1,dp1+n+1); sort(dp2+1,dp2+n+1); int max1=dp1[n]; int max2=dp2[n]; int maxi=max(max1,max2); printf("%d\n",maxi); } } return 0;}
0 0
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS++
- lis
- lis
- LIS
- Lis
- KMP
- log(三)——MDCAdapter之实现LogbackMDCAdapter
- 学渣!面对疾风吧!哈撒给
- 43. Multiply Strings
- 美团Android自动化之旅—生成渠道包
- LIS
- 基本规则
- 弄提纲【NOIP2016提高A组模拟7.19】
- Jenkins+postman+newman之API全自动化测试
- tuxedo linux 安装
- 冒泡排序代码
- 美团多渠道打包方案初体验
- 怎样在Git码云上上传项目
- ActivityThread的main方法究竟做了什么?