QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 256 MB Total points: 100

#15891. Subsequence

Statistics

Given an array $a$ and an integer $X$, you are tasked to find the longest valid subsequence of the array $a$. A subsequence is valid if and only if none of the products of neighbouring elements in the subsequence exceed $X$. That is, suppose $b$ is the subsequence of $a$ with length $m$, $b$ is valid if and only if for any $i$, where $1 \leq i \leq m-1$, $b_i \cdot b_{i+1} \leq X$.

Note: An array $b$ is a subsequence of another array $a$ if $b$ can be created by removing some elements (possibly none) from array $a$ without changing the order of elements. For example, the array $[1,3]$ is a subsequence of $[1,2,3]$, whereas the array $[2,1]$ and the array $[1,4]$ is not a subsequence of $[1,2,3]$.

Input

The first line contains two space-seperated integers, $n$ ($1 \leq n \leq 10^5$) and $X$ ($0 \leq |X| \leq 10^{18}$) -- $n$ is the length of array $a$ and $X$ is the integer given.

The second line contains $n$ space-seperated integers, $a_1, a_2, \dots, a_n$ ($1 \leq |a_i| \leq 10^9$).

Output

The only line contains an integer, which is the length of the longest valid subsequence.

Examples

Input

1 10
100

Output

1

Explanation

A subsequence of one element is always valid because there are no neighbouring elements. Therefore, the length of the longest valid subsequence is $1$.

Input

5 10
3 4 2 5 1

Output

4

Explanation

This example has a valid subsequence, $[3,2,5,1]$. It is because the product of the neighbouring elements does not exceed $10$, as shown below.

  • $3 \times 2 = 6 \,(\leq 10)$
  • $2 \times 5 = 10 \,(\leq 10)$
  • $5 \times 1 = 5 \,(\leq 5)$

The subsequence $[\underline{3,4},2,5,1]$ (i.e., the original array $a$) is invalid because the product of the first and second elements is 12, which exceeds $10$.

Therefore, the length of the longest valid subsequence is $4$.

Input

5 10
6 -2 -2 -6 5

Output

4

Explanation

The longest valid subsequence is $[6,-2,-2,5]$.

The subsequence $[6,-2,\underline{-2, -6}, 5]$ (i.e., the original array $a$) is invalid because the product of the third and fourth elements is $-2 \times -6 = 12$, which exceeds $10$.

Scoring

Subtask 1 ($5$ points): $X = 10^{18}$

Subtask 2 ($15$ points): $n \leq 20$

Subtask 3 ($20$ points): $n \leq 10^3$

Subtask 4 ($10$ points): $X \geq 0$ and $1 \leq a_i \leq 200$, for all $1 \leq i \leq n$

Subtask 5 ($20$ points): $X \geq 0$ and $1 \leq a_i \leq 10^5$, for all $1 \leq i \leq n$

Subtask 6 ($10$ points): $X \geq 0$ and $a_i \geq 1$, for all $1 \leq i \leq n$

Subtask 7 ($20$ points): No additional constraints

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.