#P2766. 最长不下降子序列问题
最长不下降子序列问题
Description
Given a sequence of positive integers .
- Compute the length of its longest non-decreasing subsequence.
- If each element is allowed to be used at most once, compute the maximum number of non-decreasing subsequences of length that can be extracted from the given sequence.
- If, in the extracted subsequences, and are allowed to be used multiple times (all other elements are still allowed to be used at most once), compute the maximum number of different non-decreasing subsequences of length that can be extracted from the given sequence.
Let be the indices used to construct , and be the indices used to construct . For all , we have and . Then and are different if and only if there exists such that .
Input Format
The first line contains a positive integer , which is the length of the given sequence. The following lines contain positive integers .
Output Format
- The first line is the length of the longest non-decreasing subsequence.
- The second line is the maximum number of non-decreasing subsequences of length that can be extracted.
- The third line is the maximum number of different non-decreasing subsequences of length that can be extracted when and are allowed to be used multiple times in the extracted subsequences.
4
3 6 2 5
2
2
3
Hint
Constraints: .
Translated by ChatGPT 5
京公网安备 11011102002149号