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. scrollTop clientTop offsetTop scrollHeight clientHeight clientWidth的差别及使用方法

    这几个属性做滚动时会经经常使用到.现总例如以下: 首先定义一个div.样式例如以下: <style> *{ margin:0px; padding:0px;} body{ margin:0 ...

  2. JAVA 自动生成对应数据库表的JPA代码工具

    http://blog.csdn.net/zheng2008hua/article/details/6274659 关键词:JPA 数据库表代码自动生成,JPA代码生成     自动生成对应数据库表的 ...

  3. NSMutableAttributedString 的使用方法,设置格式

    NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:title]; NS ...

  4. 跨discuz站获取

    1.在需要取得formhash的页面加入下面js代码,还需要jquery库. <script lanuage="javascript"> $(function(){ $ ...

  5. 给mysql root用户设置密码

    使用其他用户进入数据库, 用select PASSWORD('你要设置的密码'), 然后直接update mysql.user set  mysql.user.Password='你PASSWORD( ...

  6. Python--多进程--01

    multiprocess import multiprocessing import time def worker_1(interval): print(' i am worker1') n=5 w ...

  7. php序列化&反序列化坑

    一: 在php中如果我们统一编码是没有什么问题了,但是很多朋友会发现一个问题就是utf8和gbk编码中返回的值会有所区别: php 在utf8和gbk编码下使用serialize和unserializ ...

  8. MySQL_使用时遇到的问题汇总

    一.data too long for column 'name' at row 1 1.现象:把数据库的字符集编码设置为utf-8,通过DOS界面向表的某一列插入汉字时会遇到类似 data too ...

  9. 通过Lock对象以及Condition对象实现多线程同步

    通过Lock对象以及Condition对象实现多线程同步: 在之前的学习中,无论是通过synchronized建立同步代码块,还是通过synchronized建立同步函数,都是把对象看成一把锁来实现同 ...

  10. [转]python 书籍推荐

    原地址: http://python.jobbole.com/85620/ https://github.com/jobbole/awesome-python-books http://blog.cs ...