#C11981. Subarray Average Threshold

    ID: 41357 Type: Default 1000ms 256MiB

Subarray Average Threshold

Subarray Average Threshold

You are given an array of n integers, and two additional integers k and x. Your task is to determine whether there exists a contiguous subarray of exactly length k whose average value is greater than or equal to x. In other words, if the subarray is denoted by \(a_i, a_{i+1}, \dots, a_{i+k-1}\), you must check whether:

[ \sum_{j=0}^{k-1} a_{i+j} \geq k \times x ]

If such a subarray exists, output YES; otherwise, output NO.

Note: The condition \(\sum_{j=0}^{k-1} a_{i+j} \geq k \times x\) is equivalent to saying that the average of the subarray is at least \(x\).

inputFormat

The input is read from standard input (stdin) and has the following format:

The first line contains three space-separated integers: n k x, where n is the number of elements in the array, k is the length of the subarray to consider, and x is the target average value.

The second line contains n space-separated integers representing the elements of the array.

outputFormat

Print a single line to standard output (stdout) containing either YES if there exists a contiguous subarray of length exactly k whose average is greater than or equal to x, or NO otherwise.## sample

5 3 4
1 2 6 5 4
YES