zoukankan      html  css  js  c++  java
  • hdu 1257

    /*************************************************************************
         File Name: lcs.cpp
         Author: yubo
         Mail: yuzibode@126.com 
         Created Time: 2014年07月12日 星期六 21时30分12秒
         学习重点:
    	 test data
    
    8 389 207 155 300 299 170 158 65
    3 22 333 4444
    7 1 7 3 5 9 4 8
    6 300 500 400 400 500 300
     ************************************************************************/
    
    #include<cstring>
    #include<cstdio>
    #include<iostream>
    using namespace std;
    int a[1000];
    int dp[1000];
    int LIS(int a[],int n)
    {
    	int i,j;
    	int ans=1;
    	int m=0;
    	dp[1]=1;
    	for(i=2;i<=n;i++)
    	{
    		m=0;
    		for(j=1;j<=i;j++)
    			if(dp[j]>m&&a[j]<a[i])
    				m=dp[j];
    		dp[i]=m+1;
    		if(dp[i]>ans)
    			ans=dp[i];
    	}
    	return ans;
    
    }
    int main()
    {
    	freopen("in.txt","r",stdin);
    	int n;
    	while(scanf("%d",&n)!=EOF){
    		memset(a,0,sizeof(a));
    		for(int i=1;i<=n;i++)
    			scanf("%d",&a[i]);
    	int k=LIS(a,n);
    	printf("%d
    ",k);
    	}
    }
    

  • 相关阅读:
    MyCAT-安装配置读写分离
    MYSQL-GTID复制
    Harbor使用
    ansible-playbook(合集)
    Ansible批量添加主机
    MyCAT+MGR
    随笔说明
    常用sql语句
    接口测试基础
    正则表达式
  • 原文地址:https://www.cnblogs.com/gccbuaa/p/6823411.html
Copyright © 2011-2022 走看看