This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
const int maxn = 1e5+10; | |
int a[maxn], lis[maxn], lds[maxn]; | |
int l[maxn], r[maxn], lcnt[maxn]; | |
int main(){ | |
int n; | |
cin >> n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int longest_increasing_subsequence(int arr[], int N) | |
{ | |
int lis[N] | |
for(i = 0 to N-1) | |
lis[i] = 0 | |
lis[0] = 1 | |
for(i = 1 to N-1) | |
{ | |
for(j = 0 to i-1) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
int _lis( int arr[], int n, int *max_ref) | |
{ | |
if (n == 1) | |
return 1; | |
int res, max_ending_here = 1; | |
for (int i = 1; i < n; i++) | |
{ | |
res = _lis(arr, i, max_ref); | |
if (arr[i-1] < arr[n-1] && res + 1 > max_ending_here) |