Last active
August 29, 2015 14:17
-
-
Save ch-hristov/82606677bebf8b633220 to your computer and use it in GitHub Desktop.
Largest increasing subset
This file contains hidden or 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 <iostream> | |
| #include <stdio.h> | |
| #include <string> | |
| using namespace std; | |
| int main() | |
| { | |
| int n; | |
| cin >> n; | |
| int integers[n]; | |
| for (int i = 0; i < n; i++) | |
| cin >> integers[i]; | |
| int j[n];//n | |
| for (int i = 0; i < n; i++){ | |
| j[i] = 1; | |
| int max = 1; | |
| for (int h = 0; h < i; h++){ | |
| if (integers[i] >= integers[h]){ | |
| if (j[h] + 1 > max) | |
| max = j[h] + 1; | |
| } | |
| } | |
| j[i] = max; | |
| } | |
| cout << j[n - 1] << endl; | |
| return 0; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment