CF369A.Valera and Plates

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Valera is a lazy student. He has m clean bowls and k clean plates.

Valera has made an eating plan for the next n days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, he needs exactly one clean plate or bowl. We know that Valera can cook only two types of dishes. He can eat dishes of the first type from bowls and dishes of the second type from either bowls or plates.

When Valera finishes eating, he leaves a dirty plate/bowl behind. His life philosophy doesn't let him eat from dirty kitchenware. So sometimes he needs to wash his plate/bowl before eating. Find the minimum number of times Valera will need to wash a plate/bowl, if he acts optimally.

瓦列拉是一名懒惰的学生。他有 mm 个干净的碗和 kk 个干净的盘子。

瓦列拉为接下来的 nn 天制定了一个饮食计划。由于瓦列拉很懒,他每天恰好吃一道菜。而为了吃一道菜,他恰好需要一个干净的盘子或碗。已知瓦列拉只会做两种类型的菜肴:第一种菜肴只能用碗来吃,第二种菜肴既可以用碗也可以用盘子来吃。

瓦列拉吃完后,会留下一个脏的盘子或碗。根据他的生活哲学,他绝不会使用脏的餐具进食。因此,有时他必须在进食前清洗盘子或碗。若瓦列拉采取最优策略,求他最少需要清洗盘子或碗的次数。

输入格式

The first line of the input contains three integers n, m, k (1 ≤ n, m, k ≤ 1000) — the number of the planned days, the number of clean bowls and the number of clean plates.

The second line contains n integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 2). If a__i equals one, then on day i Valera will eat a first type dish. If a__i equals two, then on day i Valera will eat a second type dish.

输入的第一行包含三个整数 nn、mm、kk(1 ≤ n, m, k ≤ 10001 ≤ n, m, k ≤ 1000)——分别表示计划的天数、干净碗的数量和干净盘子的数量。

第二行包含 nn 个整数 a1, a2, ..., ana_1, a_2, ..., a_n(1 ≤ ai ≤ 21 ≤ a_i ≤ 2)。若 ai=1a_i = 1,则 Valera 在第 ii 天将食用第一类菜肴;若 ai=2a_i = 2,则 Valera 在第 ii 天将食用第二类菜肴。

输出格式

Print a single integer — the minimum number of times Valera will need to wash a plate/bowl.

输出一个整数——Valera 需要清洗盘子/碗的最少次数。

输入输出样例

  • 输入#1

    3 1 1
    1 2 1

    输出#1

    1
  • 输入#2

    4 3 1
    1 1 1 1

    输出#2

    1
  • 输入#3

    3 1 2
    2 2 2

    输出#3

    0
  • 输入#4

    8 2 2
    1 2 1 2 1 2 1 2

    输出#4

    4

说明/提示

In the first sample Valera will wash a bowl only on the third day, so the answer is one.

In the second sample, Valera will have the first type of the dish during all four days, and since there are only three bowls, he will wash a bowl exactly once.

In the third sample, Valera will have the second type of dish for all three days, and as they can be eaten from either a plate or a bowl, he will never need to wash a plate/bowl.

在第一个样例中,瓦莱拉仅在第三天洗一个碗,因此答案为 1。

在第二个样例中,瓦莱拉在全部四天都吃第一种菜肴,而碗的数量仅有三个,因此他恰好需要洗一次碗。

在第三个样例中,瓦莱拉在全部三天都吃第二种菜肴,而该类菜肴既可用盘子也可用碗盛装,因此他永远无需清洗盘子或碗。

输入解题思路,AI测评打分。不知道怎么写?

首页