Skip to content

Instantly share code, notes, and snippets.

@viennadd
Last active April 5, 2016 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viennadd/493e5aadfad8d93dd6ec875482005684 to your computer and use it in GitHub Desktop.
Save viennadd/493e5aadfad8d93dd6ec875482005684 to your computer and use it in GitHub Desktop.
/* DP Execrise */
#include <iostream>
using namespace std;
const int MAX_LEN = 1000;
int seq[MAX_LEN];
int lis[MAX_LEN];
int main()
{
int n;
cin >> n;
for (int i =0; i < n; ++i) {
cin >> seq[i];
lis[i] = 1;
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < i; ++j) {
if (seq[i] > seq[j]) {
lis[i] = max(lis[i], lis[j] + 1);
}
}
}
int max = 0;
for (int i : lis)
if (i > max)
max = i;
cout << max << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment