题意:最长上升子序列nlogn写法

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int dp[];
int a[];
int main(){
int n;
while(cin>>n){
for(int i=;i<n;i++){
cin>>a[i];
}
memset(dp,,sizeof(dp));
dp[]=a[];
int flag=;
for(int i=;i<n;i++){
int temp=lower_bound(dp,dp+flag,a[i])-dp;
if(dp[flag]<a[i]){
dp[++flag]=a[i];
}
else if(a[i]<dp[temp]){
dp[temp]=a[i];
}
}
cout<<flag<<endl;
}
return ;
}

Longest Ordered Subsequence POJ - 2533 最长上升子序列dp的更多相关文章

  1. Longest Ordered Subsequence POJ - 2533 dp 最长上升/不下降 子序列

    #include<iostream> using namespace std ; ; int f[N]; int a[N]; int n; int main() { cin>> ...

  2. POJ - 2533 Longest Ordered Subsequence与HDU - 1257 最少拦截系统 DP+贪心(最长上升子序列及最少序列个数)(LIS)

    Longest Ordered Subsequence A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let ...

  3. POJ 1458 最长公共子序列(dp)

    POJ 1458 最长公共子序列 题目大意:给出两个字符串,求出这样的一 个最长的公共子序列的长度:子序列 中的每个字符都能在两个原串中找到, 而且每个字符的先后顺序和原串中的 先后顺序一致. Sam ...

  4. Common Subsequence POJ - 1458 最长公共子序列 线性DP

    #include <iostream> #include <algorithm> #include <string> #include <cstring> ...

  5. poj 2533 Longest Ordered Subsequence 最长递增子序列

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4098562.html 题目链接:poj 2533 Longest Ordered Subse ...

  6. POJ 2533 - Longest Ordered Subsequence - [最长递增子序列长度][LIS问题]

    题目链接:http://poj.org/problem?id=2533 Time Limit: 2000MS Memory Limit: 65536K Description A numeric se ...

  7. POJ 2533 Longest Ordered Subsequence 最长递增序列

      Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequenc ...

  8. 题解报告:poj 2533 Longest Ordered Subsequence(最长上升子序列LIS)

    Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence ...

  9. 【POJ - 2533】Longest Ordered Subsequence (最长上升子序列 简单dp)

    Longest Ordered Subsequence 搬中文 Descriptions: 给出一个序列,求出这个序列的最长上升子序列. 序列A的上升子序列B定义如下: B为A的子序列 B为严格递增序 ...

随机推荐

  1. IT江湖--这个冬天注定横尸遍野

    今年江湖大事繁起,又至寒冬,冻的不仅是温度,更是人心. 这两天上班途中看到多个公众号和媒体发了很多 "XXX公司裁员50%" 等等诸如此类的文章,也真是撼动人心.寒冬,比以往来的更 ...

  2. Intellij Idea 教程

    Intellij Idea 教程 [涵盖安装.配置.常见问题&技巧.Maven.Git.Tomcat.快捷键.项目配置等] 目录 入门............................. ...

  3. Vue(三)之前端路由

    01-前端路由 1.前端路由的实现原理 vue+vue-router 主要来做单页面应用(Single Page Application) 为什么我们要做单页面应用? (1)传统的开发方式 url改变 ...

  4. OO生存指.....抱歉无法生存

    还记得前三次的设计策略:星期二之前实现功能,星期三找一下可能出现的小bug. 这三次以及变成了:星期二之前能跑出来就行. 总体来说设计策略是:先让几个线程能够顺利运行,再开始实现功能. 在接触到多线程 ...

  5. nginx Location 语法基础知识

    URL地址匹配是Nginx配置中最灵活的部分 Location 支持正则表达式匹配,也支持条件匹配,用户可以通过location指令实现Nginx对动丶静态网页的过滤处理. Nginx locatio ...

  6. 搜狐畅游一面(c++)

    上来是个小姐姐,有点懵.. 1.  介绍 2.  项目 3.  实习 4.  用的协议 tcp和udp的协议 5.  select 和epoll(忘了) 6. 数据库的隔离级别, 死锁, 怎么避免死锁 ...

  7. Python学习之赋值列表

    # the program aim to differentiate the defference of a=b or a=b[:] my_fruits=["apple",&quo ...

  8. 【RSYSLOG】Log4x To Rsyslog Config

    Log4x To Rsyslog Config Log4net配置 <!--RemoteSyslogAppender--> <appender name="remoteSy ...

  9. 日志之环绕通知(AOP)

    环绕通知:一个完整的try...catch...finally结构 编写环绕通知方法,环绕通知需要携带ProceedingJoinPoint 这个类型的参数,ProceedingJoinPoint类型 ...

  10. 什么是车辆识别代码(VIN)

    车辆识别代码(VIN),VIN是英文Vehicle Identification Number(车辆识别码)的缩写.因为ASE标准规定:VIN码由17位字符组成,所以俗称十七位码.正确解读VIN码,对 ...