QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 512 MB 總分: 100

#16479. Plants vs Zombies

统计

There are zombies on your lawn...

$n$ enemies will visit your lawn in the order $1$ to $n$, where the $i$-th enemy has health $a_i$. There are $m$ traps on the lawn, each with a counter, and all counters $c_1, \ldots, c_m$ are initially $0$.

Each enemy walks from trap $1$ to trap $2$, and so on, up to trap $m$. If an enemy is still alive after passing all traps, it will eat your brain. Meanwhile, traps deal damage to enemies: when an enemy passes a trap, its health decreases by $1$, and the corresponding trap's counter increases by $1$. An enemy dies if and only if its health is no greater than $0$. At this point, it is buried under the lawn and stops moving.

You can spend one gold coin to activate any trap $x \in [1, m]$. Once activated, if an enemy passes trap $x$ and the counter $c_x$ becomes a multiple of $k$ after being incremented, the enemy's health will immediately drop to $0$, and it will stop moving.

You want to know the minimum number of gold coins required to prevent your brain from being eaten. Specifically, if it is impossible to achieve the goal regardless of which traps are activated, output Zombies are on your lawn.

Input

The first line contains three integers $n$, $m$, and $k$ ($1 \leq n \leq 100$, $1 \leq m \leq 100$, $1 \leq k \leq 3$).

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq m + 1$).

Output

Output a single integer representing the minimum number of gold coins required. If it is impossible to achieve the goal, output Zombies are on your lawn.

Examples

Input 1

5 4 2
1 3 5 2 5

Output 1

1

Input 2

6 6 3
1 2 7 5 7 7

Output 2

2

Input 3

15 8 3
1 4 7 1 5 4 9 9 8 2 4 4 3 5 3

Output 3

3

Input 4

1 2 2
3

Output 4

Zombies are on your lawn

Input 5

20 10 3
10 6 6 2 11 11 8 6 3 11 10 4 11 5 3 5 2 9 10 5

Output 5

3

Note

For the first example, activating only trap $2$ is optimal. For each $1 \leq i \leq 5$, after the $i$-th enemy passes the lawn, the counters $c_1, \ldots, c_m$ are as follows:

  • $[1, 0, 0, 0, 0]$;
  • $[2, 1, 1, 0, 0]$;
  • $[3, 2, 1, 0, 0]$;
  • $[4, 3, 1, 0, 0]$;
  • $[5, 4, 1, 0, 0]$.

For the second example, one optimal strategy is to activate traps $1$ and $2$.

For the fourth example, it is impossible to ensure your brain is not eaten.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.