Last active
April 5, 2016 16:33
-
-
Save viennadd/493e5aadfad8d93dd6ec875482005684 to your computer and use it in GitHub Desktop.
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
/* 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