#K14971. Taco: Substantial Increase Check

    ID: 24253 Type: Default 1000ms 256MiB

Taco: Substantial Increase Check

Taco: Substantial Increase Check

Given the prices of an item over n days, determine whether there exists a contiguous subarray of exactly d days such that the price on the last day is at least k units higher than the price on the first day.

Formally, given a sequence \(\{p_1, p_2, \ldots, p_n\}\), check if there exists an index \(i\) with \(1 \le i \le n-d+1\) such that:

\(p_{i+d-1} - p_i \ge k\)

If such a subarray exists, print Possible; otherwise, print Impossible.

inputFormat

The input is read from standard input and consists of two lines:

  • The first line contains three integers \(n\), \(d\), and \(k\): the number of days, the required subarray length, and the minimum required increase, respectively.
  • The second line contains \(n\) space-separated integers representing the prices on each day.

For example:

7 3 4
5 3 6 9 4 10 8

outputFormat

Output a single line to standard output containing either Possible if there is a subarray of exactly d days where the price difference between the last and first day is at least k, or Impossible otherwise.

For example, the sample input above should output:

Possible
## sample
7 3 4
5 3 6 9 4 10 8
Possible