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. iOS语言本地化,中文显示

    尽管一直相信xcode肯定提供有语言本地化的设置地方,可是一直也没凑着去改.非常多的汉化,还是使用代码去控制:比方navagition的return使用代码改动为"返回"! 近期在 ...

  2. 下拉刷新Listview(8.30)

    Android-PullToRefresh 1项目托管地址: https://github.com/bavariama1/Android-PullToRefresh 2 快速开始教程:https:// ...

  3. 【ExtAspNet学习笔记】ExtAspNet控件库中常见问题

    1.在Grid控件中添加CheckBoxField控件,选择一行时,如何获取选择的CheckBoxField所对应记录的唯一标识值? ●解决方案: 在前台Grid控件中, 添加“<ext:Che ...

  4. javascript 在js文件中获取路径

    如果在*.js文件中获取当自己当前的路径是很重要的. 举个例子,如果一个css文件中引用图片,如background-img: url('./Images/bg.png').那么图片的路径,是相对于c ...

  5. Python调用API接口的几种方式 数据库 脚本

    Python调用API接口的几种方式 2018-01-08 gaoeb97nd... 转自 one_day_day... 修改 微信分享: 相信做过自动化运维的同学都用过API接口来完成某些动作.AP ...

  6. 蒙特卡洛方法计算圆周率的三种实现-MPI openmp pthread

    蒙特卡洛方法实现计算圆周率的方法比较简单,其思想是假设我们向一个正方形的标靶上随机投掷飞镖,靶心在正中央,标靶的长和宽都是2 英尺.同时假设有一个圆与标靶内切.圆的半径是1英尺,面积是π平方英尺.如果 ...

  7. Ueditor编辑器图片上传到万象优图

    最近想用typecho做一个个人博客站,typecho的文本编辑器不能上传图片,我就用Ueditor替换的了原来的文本编辑器,听说腾讯的万象优图每月有50G的免费空间和流量,我就自己改了下Uedito ...

  8. saltstack之软件管理

    1.installed安装软件包 例: 安装NFS /srv/salt/pkg/nfs.sls nfs: pkg.installed: - pkgs: - nfs-utils 在命令行执行如下 sal ...

  9. proxool连接池 异常

    这是第二次整理这个文章: 首先说明proxool连接池有两种配置方式: 第一种:采用jdbc.properties的方式 第二种:采用proxool.xml的配置方 后面在完善这两种配置方式(在上班哦 ...

  10. css 坑记

    1. div 内容超出 (做换行处理)   要注意 white-space属性的运用 设置 div width:100%;(或者固定值) 设置换行  word-break: break-all; 设置 ...