#K54227. Longest Increasing Subsequence Query
Longest Increasing Subsequence Query
Longest Increasing Subsequence Query
You are given an array of N integers and Q queries. For each query, you must determine if there exists a strictly increasing subsequence of the array whose length is at least K (the query value).
The task requires you to first compute the length of the Longest Increasing Subsequence (LIS) of the given array. The LIS is defined as the longest subsequence such that every element in the subsequence is greater than the previous one. Mathematically, if we denote the LIS length as \(LIS\), then for a query value \(K\), the answer is "YES" if \(K \leq LIS\) and "NO" otherwise.
Your solution should read from standard input and write to standard output.
inputFormat
The first line contains two integers N and Q — the number of elements in the array and the number of queries respectively.
The second line contains N space-separated integers representing the array.
The third line contains Q space-separated integers where each integer is a query value K.
Note: All input is given via standard input.
outputFormat
For each query, output "YES" if there exists a strictly increasing subsequence of length at least K; otherwise, output "NO". Each answer should be printed on a new line to standard output.
## sample7 4
9 1 3 7 5 6 20
3 5 8 2
YES
YES
NO
YES
</p>