diff --git a/c++/Longest_increasing_subsequence1.cpp b/c++/Longest_increasing_subsequence1.cpp new file mode 100644 index 0000000..c5a32fb --- /dev/null +++ b/c++/Longest_increasing_subsequence1.cpp @@ -0,0 +1,42 @@ +#include +using namespace std; + +#define int long long +#define double long double +#define pb push_back +#define mp make_pair +#define eb emplace_back +#define ppi pair +#define fast ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL) +#define input freopen("input.txt","r",stdin),freopen("output.txt","w",stdout) +#define rep(i,j,n) for(int i=j;i v; + int n; + cin>>n; + rep(i,0,n){ + int a; + cin>>a; + v.pb(a); + } + int lis[n]; + + lis[0]=1; + for (int i = 1; i < n; i++) { + lis[i] = 1; + for (int j = 0; j < i; j++) + if (v[i] > v[j] && lis[i] < lis[j] + 1) + lis[i] = lis[j] + 1; + } + sort(lis,lis+n); + cout<