#C10859. Continuous Flower Planting

    ID: 40110 Type: Default 1000ms 256MiB

Continuous Flower Planting

Continuous Flower Planting

You are given a garden represented as a sequence of spots and an integer m which is the number of flowers you want to plant. Each spot is represented by an integer where 0 indicates an empty spot and 1 indicates an occupied spot (a rock). Your task is to determine whether it is possible to plant m flowers in a continuous segment of empty spots.

Mathematically, if we denote the garden as an array \(A\) of length \(n\), you need to check if there exists a contiguous subsequence of \(k\) consecutive integers (with \(k \ge m\)) such that every element in that subsequence is 0. In other words, you need to determine if \[ \max_{\text{segments}} (\text{length of continuous zeros}) \ge m. \]

Note: The input will be provided via standard input and the output should be printed to the standard output.

inputFormat

The input will be provided via standard input (stdin) in the following format:

  1. An integer n representing the number of spots in the garden.
  2. A line containing n space-separated integers (each 0 or 1) representing the garden.
  3. An integer m representing the number of flowers you want to plant.

If n is 0, then the garden is empty.

outputFormat

Output a single line to standard output (stdout) containing either True or False (without quotes) depending on whether it is possible to plant m flowers in a continuous segment of empty spots.

## sample
7
1 0 0 0 1 0 0
3
True