#K68542. Longest Double Subsequence
Longest Double Subsequence
Longest Double Subsequence
You are given an array of n integers. Your task is to find the length of the longest subsequence such that for every consecutive pair of elements ai-1 and ai in the subsequence, the following condition holds:
\(a_i \ge 2a_{i-1}\)
A subsequence is obtained by deleting some (or no) elements from the array without changing the order of the remaining elements. If the array is empty, then the answer is 0.
Note: The subsequence is not necessarily contiguous.
inputFormat
The input consists of two lines. The first line contains a single integer n representing the number of elements in the array. The second line contains n space-separated integers.
If n equals 0, then the second line will be empty.
outputFormat
Output a single integer which is the length of the longest subsequence where each element is at least double its predecessor.
## sample6
3 5 6 13 26 50
4