http://www.geeksforgeeks.org/longest-monotonically-increasing-subsequence-size-n-log-n/

 #include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <fstream>
#include <map>
using namespace std; int maxsum(int arr[], int n) {
vector<int> tail;
tail.push_back(arr[]);
for (int i = ; i < n; i++) {
if (arr[i] < tail[]) tail[] = arr[];
else if (arr[i] > tail[tail.size()-]) tail.push_back(arr[i]);
else {
int mid;
int left = ;
int right = tail.size() - ;
while (left < right) {
mid = (left + right) / ;
if (tail[mid] < arr[i]) left = mid + ;
else right = mid - ;
}
mid = (left + right) / ;
tail[mid] = arr[i];
cout << "tail[" << mid << "] is arr[" << i << "] = " << arr[i] << endl;
}
}
return tail.size();
} int main() {
int arr[] = {, , , , , , , , };
cout << maxsum(arr, ) << endl;
return ;
}

Data Structure Array: Longest Monotonically Increasing Subsequence Size的更多相关文章

  1. [LeetCode] Longest Continuous Increasing Subsequence 最长连续递增序列

    Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...

  2. LeetCode 674. Longest Continuous Increasing Subsequence最长连续递增序列 (C++/Java)

    题目: Given an unsorted array of integers, find the length of longest continuous increasing subsequenc ...

  3. [LeetCode] 674. Longest Continuous Increasing Subsequence 最长连续递增序列

    Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...

  4. LeetCode 674. Longest Continuous Increasing Subsequence (最长连续递增序列)

    Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...

  5. [Swift]LeetCode674. 最长连续递增序列 | Longest Continuous Increasing Subsequence

    Given an unsorted array of integers, find the length of longest continuous increasing subsequence (s ...

  6. [Leetcode]674. Longest Continuous Increasing Subsequence

    Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...

  7. [LeetCode&Python] Problem 674. Longest Continuous Increasing Subsequence

    Given an unsorted array of integers, find the length of longest continuousincreasing subsequence (su ...

  8. leetcode300. Longest Increasing Subsequence 最长递增子序列 、674. Longest Continuous Increasing Subsequence

    Longest Increasing Subsequence 最长递增子序列 子序列不是数组中连续的数. dp表达的意思是以i结尾的最长子序列,而不是前i个数字的最长子序列. 初始化是dp所有的都为1 ...

  9. 674. Longest Continuous Increasing Subsequence最长连续递增子数组

    [抄题]: Given an unsorted array of integers, find the length of longest continuous increasing subseque ...

随机推荐

  1. 打造Android万能上拉下拉刷新框架--XRefreshView(三)

    转载请注明出处:http://blog.csdn.net/footballclub/ 打造Android万能上拉下拉刷新框架–XRefreshView(一) 打造Android万能上拉下拉刷新框架–X ...

  2. 通过Cloudera Manager安装CDH 5.6

    CDH的简介 大家常常说CDH.其全称是:Cloudera's Distribution Including Apache Hadoop.简单的说是Cloudera公司的Hadoop平台,是在Apac ...

  3. Cocos2d-x教程(35)-三维拾取Ray-AABB碰撞检測算法

    欢迎增加Cocos2d-x 交流群:193411763 转载时请注明原文出处 :http://blog.csdn.net/u012945598/article/details/39927911 --- ...

  4. shell中的括号作用

    一.小括号,圆括号() 1.单小括号 ()    ①命令组.括号中的命令将会新开一个子shell顺序执行,所以括号中的变量不能够被脚本余下的部分使用.括号中多个命令之间用分号隔开,最后一个命令可以没有 ...

  5. sublime使用技巧(3)-- 常用快捷键【持续更新】

    ♥ Ctrl + Shift + v 这样粘贴可以保持原格式,不会有缩进上的困扰 Ctrl + k 用Ctrl + d选中重复单词时跳过当前选中 Ctrl + Enter 在光标所在行的下一行新建一行 ...

  6. cobbler+koan

    cobbler+koan自动重装客户机   koan是kickstart-over-a-network的缩写,它是cobbler的客户端帮助程序,koan允许你通过网络提供虚拟机,也允许你重装已经存在 ...

  7. 题外话:计算密集型 vs IO密集型

    我们把任务分为计算密集型和IO密集型,erlang作为IO密集型的语言,适合网关等相关的场景,而对计算达到某一量级后,可能处理效率下降的很明显. erlang不适合数值计算.erlang是解释型的,虽 ...

  8. 常用PHP array数组函数

    array_rand  第二个参数用来确定要选出几个元素 如果选出的元素不止一个,则返回包含随机键名的数组,否则返回该元素的键名. $a=array("red","gre ...

  9. COM组件多接口对象模型

    COM组件有两种接口类型,Dual and Custom,如下图所示.本文说的是Custom.所谓多接口COM对象是指此COM对象实现了多于一个的自定义接口,即Custom接口. 接口图如下: 需要注 ...

  10. C# .Net 下 x86使用大内存的处理

    /LARGEADDRESSAWARE 选项通知链接器应用程序可处理大于 2 GB 的地址. 在 64 位编译器中,默认情况下启用此选项. 在 32 位编译器中,如果未在链接器行上指定 /LARGEAD ...