POJ3903 Stock Exchange

 #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn = 1e5+;
int a[maxn];
int main() {
int n;
while (~scanf("%d",&n)) {
for (int i = ; i <= n; ++i) scanf("%d",&a[i]);
vector<int> ve;
ve.push_back(a[]);
for (int i = ; i <= n; ++i) {
if (ve[ve.size()-] < a[i]) {
// 如果新进来的数比最后一个数大,那么直接插入
ve.push_back(a[i]);
}
else {
ve[lower_bound(ve.begin(),ve.end(),a[i])-ve.begin()] = a[i];
}
}
printf("%d\n",ve.size());
}
return ;
}

POJ3903 Stock Exchange LIS最长上升子序列的更多相关文章

  1. poj3903 Stock Exchange(最长上升子序列)

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:id=3903">http://poj.org/problem?id=3903 Descrip ...

  2. poj 3903 Stock Exchange(最长上升子序列,模版题)

    题目 #include<stdio.h> //最长上升子序列 nlogn //入口参数:数组名+数组长度,类型不限,结构体类型可以通过重载运算符实现 //数组下标从1号开始. int bs ...

  3. {POJ}{3903}{Stock Exchange}{nlogn 最长上升子序列}

    题意:求最长上升子序列,n=100000 思路:O(N^2)铁定超时啊....利用贪心的思想去找答案.利用栈,每次输入数据检查栈,二分查找替换掉最小比他大的数据,这样得到的栈就是更优的.这个题目确实不 ...

  4. POJ 3903 Stock Exchange 【最长上升子序列】模板题

    <题目链接> 题目大意: 裸的DP最长上升子序列,给你一段序列,求其最长上升子序列的长度,n^2的dp朴素算法过不了,这里用的是nlogn的算法,用了二分查找. O(nlogn)算法 #i ...

  5. POJ - 3903 Stock Exchange(LIS最长上升子序列问题)

    E - LIS Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u   Descripti ...

  6. POJ 3903 Stock Exchange (E - LIS 最长上升子序列)

    POJ 3903    Stock Exchange  (E - LIS 最长上升子序列) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action ...

  7. 算法设计 - LCS 最长公共子序列&&最长公共子串 &&LIS 最长递增子序列

    出处 http://segmentfault.com/blog/exploring/ 本章讲解:1. LCS(最长公共子序列)O(n^2)的时间复杂度,O(n^2)的空间复杂度:2. 与之类似但不同的 ...

  8. hdu 5256 序列变换(LIS最长上升子序列)

    Problem Description 我们有一个数列A1,A2...An,你现在要求修改数量最少的元素,使得这个数列严格递增.其中无论是修改前还是修改后,每个元素都必须是整数. 请输出最少需要修改多 ...

  9. 动态规划模板1|LIS最长上升子序列

    LIS最长上升子序列 dp[i]保存的是当前到下标为止的最长上升子序列的长度. 模板代码: int dp[MAX_N], a[MAX_N], n; int ans = 0; // 保存最大值 for ...

随机推荐

  1. 【转帖】Python 重复造轮子/造轮子找模子,你都应该熟读该文

    Chardet,字符编码探测器,可以自动检测文本.网页.xml的编码. colorama,主要用来给文本添加各种颜色,并且非常简单易用. Prettytable,主要用于在终端或浏览器端构建格式化的输 ...

  2. 字符串的z型转换

    class Solution(object):     def convert(self, s, numRows):         if numRows==1:             return ...

  3. ansible的语法的基础应用(二)

         

  4. Task Scheduler Error Message: 80041318

    Using the error lookup tool that comes with VC++ (errlook.exe, or "Error Lookup" on the To ...

  5. Windows 计划任务 如果选择未登录就运行 则看不到GUI

    You can specify that a task should run even if the account under which the task is scheduled to run ...

  6. Golang——Cron 定时任务

    开门见山写一个 package main import ( "fmt" "github.com/robfig/cron" "log" &qu ...

  7. MyBaties一级缓存

    2019独角兽企业重金招聘Python工程师标准>>> 一.一级缓存简介 在系统代码的运行中,我们可能会在一个数据库会话中,执行多次查询条件完全相同的Sql,鉴于日常应用的大部分场景 ...

  8. ajax学习摘抄笔记

    2019独角兽企业重金招聘Python工程师标准>>> AJAX = Asynchronous JavaScript and XML(异步的 JavaScript 和 XML). A ...

  9. P3831 [SHOI2012]回家的路

    P3831 [SHOI2012]回家的路 分层图基础题,就是建图稍有麻烦   #include<cstdio> #include<algorithm> #include< ...

  10. 微软2016校园招聘在线笔试之Magic Box

    题目1 : Magic Box 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 The circus clown Sunny has a magic box. When ...