AT_code_festival_2015_okinawa_i Implementation Addict

题目描述

Wolf Sothe 非常喜欢解决在线评测系统中的问题,他希望尽可能多地完成这些问题。然而,如果他每天都不间断地进行解题,随着天数的增加,能够解决的问题数量会逐渐减少。 所以,有时 Wolf Sothe 会选择休息一天。在这一天里,他不会解题,但这能使他在接下来的日子里恢复效率。 每天,Wolf Sothe 能够解决的问题数量取决于以下规则: - 如果那天是工作日,定义 Wolf Sothe 已经连续解题的天数为 $k$(当天不算在内)。那么他可以解决的问题数量是 $ \max(0, A - k \times B) $。 - 如果那天是休息日,则当天解决的问题数量为 0。 Wolf Sothe 有 $N$ 天的时间,他希望在这段时间内尽可能多地解决问题。假设他在第 1 天之前没有解过题。 此外,我们事先知道有一些已经决定的休息日。 这些确定的休息日会以列表形式给出。对于其他日子,你可以选择标记为休息日或者工作日。请规划安排,以使得在这 $N$ 天内 Wolf Sothe 能解决的总问题数最大。

输入格式

输入通过标准输入给出,格式如下: > $ N\ A\ B\ M\ t_1\ t_2\ \ldots\ t_M $ - 第一行包含四个整数 $ N (1 \leq N \leq 1,000,000,000) $、$ A (1 \leq A \leq 1,000,000,000) $、$ B (1 \leq B \leq 1,000,000,000) $ 和 $ M (0 \leq M \leq 100,000) $,它们之间用空格分隔。这里 $M$ 代表已经确定的休息日数量。 - 随后的 $M$ 行每行为一个整数 $ t_i (1 \leq t_i \leq N) $,表示第 $t_i$ 天是已确定的休息日。注意 $ t_i $ 是按升序排列的。

输出格式

输出在这 $N$ 天内 Wolf Sothe 所能解决的最多问题总数,结果输出一行并在末尾换行。 ### 示例解释 1 假设 Wolf Sothe 在第 3 天休息,并在剩余的 4 天解题: - 第 1 天,没连续解题的天数是 0,所以解决了 $\max(0, 6 - 0 \times 2) = 6$ 个问题。 - 第 2 天,已经连续解了 1 天题,解决了 $\max(0, 6 - 1 \times 2) = 4$ 个问题。 - 第 3 天,他选择休息,没解决任何问题。 - 第 4 天,恢复到没连续解题的状态,解决了 $\max(0, 6 - 0 \times 2) = 6$ 个问题。 - 第 5 天,再次连续解题 1 天,解决了 $\max(0, 6 - 1 \times 2) = 4$ 个问题。 最终,共解决了 $6 + 4 + 0 + 6 + 4 = 20$ 个问题。 **本翻译由 AI 自动生成**

说明/提示

### Problem Wolf Sothe loves implementing online judge problems, he wants to solve as many problems as possible. However, if he keeps solving problems every day without a rest, day by day the number of problems that can be solved in a day will reduce. So, sometimes Wolf Sothe takes a day off. On that day, Wolf Sothe will not solve any problem, then for the next day and later Wolf Sothe will be able to solve problems. The number of problems that Wolf Sothe can solve in a day is as follows: - If that day is a working day, we define the number of days that Wolf Sothe has kept solving problems as $ k $ (not including that day). Then Wolf Sothe can solve $ max(0,\ A\ −\ k\ \times\ B) $ problems during that day. - If that day is a rest day, during that day no problem will be solved. Wolf Sothe wants to solve problems for $ N $ days. Let the $ N $ days be as a sequence from the 1st day to the $ N_{th} $ day. Suppose that Wolf Sothe doesn't solve problems before the 1st day. In addition, we known in advance that there are some decided rest days. A list of all the decided rest days will be given. For any other day, you can mark it as a rest day or a working day. Please find the maximum value of the number of problems that can be solved during $ N $ days. ### Sample Explanation 1 Suppose that Wolf Sothe rest on the 3rd day and solve problems on the remaining $ 4 $ days. - For the 1st day, Wolf Sothe has kept solving problems for $ 0 $ day. Thus, $ max(0,\ 6\ −\ 0\ \times\ 2)\ =\ 6 $ problems. - For the 2nd day, Wolf Sothe has kept solving problems for $ 1 $ day. Thus, $ max(0,6\ −\ 1\ \times\ 2)\ =\ 4 $ problems. - For the 3rd day, Wolf Sothe rests. Thus, $ 0 $ problem. - For the 4th day, Wolf Sothe has kept solving problems for $ 0 $ day. Thus, $ max(0,\ 6\ −\ 0\ \times\ 2)\ =\ 6 $ problems. - For the 5th day, Wolf Sothe has kept solving problems for $ 1 $ day. Thus, $ max(0,\ 6\ −\ 1\ \times\ 2)\ =\ 4 $ problems. In conclusion, $ 6\ +\ 4\ +\ 0\ +\ 6\ +\ 4\ =\ 20 $ will be solved in total.