#P15278. [MCO 2025] Subsequence
[MCO 2025] Subsequence
Description
Given an array and an integer , you are tasked to find the longest subsequence of the array . A subsequence is if and only if none of the products of neighbouring elements in the subsequence exceed . That is, suppose is the subsequence of with length , is if and only if for any , where , .
Note: An array is a subsequence of another array if can be created by removing some elements (possibly none) from array without changing the order of elements. For example, the array is a subsequence of , whereas the array and the array is \textbf{not} a subsequence of .
Input Format
The first line contains two space-seperated integers, () and () -- is the length of array and is the integer given.
The second line contains space-seperated integers, ().
Output Format
The only line contains an integer, which is the length of the longest subsequence.
1 10
100
1
5 10
3 4 2 5 1
4
5 10
6 -2 -2 -6 5
4
Hint
Note
A subsequence of one element is always valid because there are no neighbouring elements. Therefore, the length of the longest subsequence is .
This example has a subsequence, . It is because the product of the neighbouring elements does not exceed , as shown below.
The subsequence (i.e., the original array ) is because the product of the first and second elements is 12, which exceeds .
Therefore, the length of the longest subsequence is .
The longest subsequence is .
The subsequence (i.e., the original array ) is because the product of the third and fourth elements is , which exceeds .
Scoring
Subtask 1 ( points):
Subtask 2 ( points):
Subtask 3 ( points):
Subtask 4 ( points): and , for all
Subtask 5 ( points): and , for all
Subtask 6 ( points): and , for all
Subtask 7 ( points): No additional constraints
京公网安备 11011102002149号