QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#16479. Plants vs Zombies

统计

题目描述

There are zombies on your lawn...

$n$ 名敌人将会按照 $1 \sim n$ 的顺序依次拜访你的草坪,其中,第 $i$ 名敌人有血量 $a_i$。草坪上有 $m$ 处陷阱,每处陷阱上都有一个计数器,且所有计数器的值 $c_1, \ldots, c_m$ 初始均为 $0$。

每名敌人都会从第 $1$ 处陷阱走到第 $2$ 处陷阱,一直走到第 $m$ 处陷阱,如果它在经过所有陷阱后尚未死亡,它就会吃掉你的脑子。与此同时,陷阱会对敌人造成伤害,一名敌人经过一处陷阱时,其血量会减少 $1$,而对应陷阱的计数器会增加 $1$。一个敌人死亡,当且仅当它的生命值 不高于 $0$。此时,它会被埋葬在草坪下,并不再继续移动。

你可以花费一枚金币,激活任意一处 $x \in [1, m]$ 的陷阱 $x$。激活后,当某名敌人经过陷阱 $x$,此时 $c_x$ 增加 $1$ 后,恰好变为了 $k$ 的倍数,那么这名敌人的血量将会立刻降低至 $0$,并不再继续移动。

你想要知道,最少花费多少枚金币,就能防止自己的脑子被敌人吃掉。特别地,如果无论如何激活陷阱都无法达成目标,则输出 $\texttt{Zombies are on your lawn}$。

输入格式

第一行,三个整数 $n$,$m$ 和 $k$($1 \leq n \leq 100$,$1 \leq m \leq 100$,$\color{red}{1 \leq k \leq 3}$)。

第二行,$n$ 个整数 $a_1, a_2, \ldots, a_n$($1 \leq a_i \leq m + 1$)。

输出格式

输出仅一行一个整数,表示最少花费的金币数目。如果无论如何激活陷阱都无法达成目标,输出 $\texttt{Zombies are on your lawn}$。

样例

样例输入 1

5 4 2
1 3 5 2 5

样例输出 1

1

样例输入 2

6 6 3
1 2 7 5 7 7

样例输出 2

2

样例输入 3

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

样例输出 3

3

样例输入 4

1 2 2
3

样例输入 4

Zombies are on your lawn

样例输入 5

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

样例输出 5

3

样例解释

对于第一组样例,只激活陷阱 $2$ 是最优的。对每个 $1 \leq i \leq 5$,第 $i$ 名敌人经过草坪后,计数器 $c_1, \ldots, c_m$ 的情况如下:

  • $[1, 0, 0, 0, 0]$;
  • $[2, 1, 1, 0, 0]$;
  • $[3, \color{blue}{2}, \color{black} 1, 0, 0]$;
  • $[4, 3, 1, 0, 0]$;
  • $[5, \color{blue}{4}, \color{black} 1, 0, 0]$。

对于第二组样例,其中一种最优方案是激活陷阱 $1$ 和 $2$。

对于第四组样例,无法保证你的脑子不被吃掉。

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.