Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int n;
- cin >> n;
- for (int i = 0; i < n; i++)
- {
- cin >> mas[i];
- }
- dp[0] = 1;
- int num = 0;
- for (int i = 1; i < n; i++)
- {
- dp[i] = 1;
- for (int j = 0; j < i; j++)
- {
- if (mas[j] < mas[i])
- {
- dp[i] = max(dp[i], dp[j] + 1);
- }
- }
- }
- int ans = dp[0];
- for (int i = 1; i < n; i++)
- {
- ans = max(ans, dp[i]);
- }
- cout << ans;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement