#K1476. Consecutive Population Growth Sequence
Consecutive Population Growth Sequence
Consecutive Population Growth Sequence
In this problem, you are given a sequence of integer values representing the population of a town for consecutive years and an integer ( k ). Your task is to determine if there exists at least one contiguous subsequence of ( k ) consecutive years during which the population strictly increases year over year. If such a subsequence exists, print YES
; otherwise, print NO
.
Example:
For a sequence: [100, 101, 102, 100, 105, 106] and ( k = 3 ), the subsequence [100, 101, 102] shows consecutive growth, so the answer is YES
.
inputFormat
The first line contains two integers ( n ) and ( k ), where ( n ) is the number of years and ( k ) is the length of the subsequence to check. The second line contains ( n ) space-separated integers representing the population data for each year.
outputFormat
Output a single line containing either YES
if there exists at least one consecutive subsequence of ( k ) years with strictly increasing population, or NO
otherwise.## sample
6 3
100 101 102 100 105 106
YES
</p>