#K58342. K-Consecutive Increasing Subsequence
K-Consecutive Increasing Subsequence
K-Consecutive Increasing Subsequence
Given a sequence of ( n ) integers and an integer ( k ), determine if there exists a contiguous subsequence of length at least ( k ) where each element is strictly greater than its preceding element. In other words, check if there exists an index ( i ) such that ( a_{i} < a_{i+1} < \cdots < a_{i+k-1} ). If such a subsequence exists, output YES
; otherwise, output NO
.
inputFormat
The input is given via standard input (stdin) in the following format:
- The first line contains two integers ( n ) and ( k ), where ( n ) is the number of elements in the sequence and ( k ) is the minimum required length of the increasing subsequence.
- The second line contains ( n ) space-separated integers representing the sequence.
outputFormat
Output a single line to standard output (stdout) containing YES
if there exists a contiguous subsequence of at least ( k ) consecutive increasing numbers; otherwise, output NO
.## sample
10 3
1 2 2 3 4 5 1 1 1 6
YES