Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 300 + 11;
- int dp[N], a[N];
- int main()
- {
- int n;
- cin >> n;
- for (int i = 0; i < n; i++) {
- cin >> a[i];
- }
- dp[0] = 1;
- for (int i = 1; i < n; i++) {
- dp[i] = 1;
- for (int j = 0; j < i; j++) {
- if (a[j] < a[i]) {
- dp[i] = max(dp[i], dp[j] + 1);
- }
- }
- }
- int ans = -1;
- for (int i = 0; i < n; i++) {
- ans = max(ans, dp[i]);
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement